[Freeciv-Dev] [patch #3495] Starting with first city placed
Update of patch #3495 (project freeciv): Status: Ready For Test = Done Assigned to:None = cazfi Open/Closed:Open = Closed ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Update of patch #3495 (project freeciv): Status: In Progress = Ready For Test Planned Release: = 2.5.0 ___ Follow-up Comment #16: Attached patch adds boolean server setting startcity controlling whether player starts with first city already in place or not. (file #16662) ___ Additional Item Attachment: File name: StartCity.patchSize:3 KB ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #15, patch #3495 (project freeciv): This last point is actually why I think this must be implemented in ruleset C-code. Server must be aware of the fact that city will be founded to starting location before it assigns those locations. I agree. ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Update of patch #3495 (project freeciv): Category:None = general Status:None = In Progress ___ Follow-up Comment #12: No Problem - thanks for testing the code! In comment #6 two missing lua functions were mentioned. One is implemented in comment #5 (Player find.leader (nation_name)). Should it be inserted into tolua_game.pkg? ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #13, patch #3495 (project freeciv): Should it be inserted into tolua_game.pkg? Yes, it should be inserted into tolua_game.pkg and api_game_find.c ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #4, patch #3495 (project freeciv): I think the player attribute should not be changed at this point as player is the information that is needed to create a city. A nation must not exist on the map. What about a new lua function player get_player(Nation_Type pnation) which returns the player of that nation if it exists. If not it would return NULL and you would know that first a player with the required nation has to be created. Such a function would not require much work ... ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #5, patch #3495 (project freeciv): It should even work using lua. Below an (untested) function: [code] function search_player_with_nation(nation_str) for player in players_iterate() do local plr_nation_str = player.nation:rule_name() if (nation_str == plr_nation_str) return player end end return NIL end [/code] It returns with player with nation 'nation_str' if it exists, else NIL. The player can then be used in the functions to create the city, etc. Question: should such functions be collected in something like a lua (example) library? I think such functions helps to learn lua and are perhaps rewritten as their existence is not known. It could be default.lua in the ruleset directories or functions.lua in ./data. I know about function usefull for longturn to create new players which were posted here long ago ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #6, patch #3495 (project freeciv): According to http://freeciv.wikia.com/wiki/Lua_reference_manual#find this would be (if it is working) the missing function: Player find.leader (nation_name) Similar the function: Player find.player (player_name) Could be implemented using only lua. ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #7, patch #3495 (project freeciv): According to http://freeciv.wikia.com/wiki/Lua_reference_manual#find this would be (if it is working) the missing function: Player find.leader (nation_name) It's not working. Original (working) local owner = find.player(0) Test (not working) local owner = find.leader(Swedish) local owner = find.leader('Swedish') local owner = find.leader(Swedish) local owner = find.leader(nation_swedish) local owner = find.leader('nation_swedish') local owner = find.leader(nation_swedish) Error: [string script.code]:4: attempt to call field 'leader' (a nil value) Question: should such functions be collected in something like a lua (example) library? I don't know. I write my function in scenario files between [script] code=$ and $. Now I test the (untested) function, but... Where should I insert? Function turn_cb(turn, year) or function city_nation_swedish()? ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #8, patch #3495 (project freeciv): Sorry about the confusion; I mean the function in comment #5 would be the currently missing function find.leader(nation_name) implemented in lua. The function find.player(player_name) could be implemented similar. I can't test it at the moment ... ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #9, patch #3495 (project freeciv): Sorry about the confusion; I mean the function in comment #5 would be the currently missing function find.leader(nation_name) implemented in lua. The function find.player(player_name) could be implemented similar. I can't test it at the moment ... No problem. Thanks for your help! ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #10, patch #3495 (project freeciv): Now I test the (untested) function, but... Where should I insert? Function turn_cb(turn, year) or function city_nation_swedish()? The function should be inserted on its own (separate function). After that you could change your function as follows: function city_nation_swedish() local owner = search_player_with_nation(Swedish) if owner then local Stockholm = find.tile(208,93) create_city(owner, Stockholm, 'Stockholm') else log.error(No player with nation 'Swedish') end end (all untested) ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #11, patch #3495 (project freeciv): The function should be inserted on its own (separate function). After that you could change your function as follows. Congratulations! Working! You missed only: [...] if (nation_str == plr_nation_str) *then* return player end [...] without *then* it's not working :) Thanks Syntron! ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #3, patch #3495 (project freeciv): From server/scripting/api_server_edit.c: void api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, const char *name) Is it possible add ''Nation_Type *pnation'' at the API? If it's not possible maybe create new API with ''Nation_Type *pnation''. ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #2, patch #3495 (project freeciv): I used to insert in script.lua a function. Or in a scenario files between: [script] code=$ $ but it's not simply for novice. I have a scenario (Europe 350*350 - S_3) where I generate 617 cities at the start. The problem are nations! If I use script lua: local owner = find.player(0) Maybe player(0) is Poland or Greece or United Kingdom, but Stockholm is Swedish! I tried find.nation_type('nameofthenation') and find.nation_type(nameofthenation), but both don't run. ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
URL: http://gna.org/patch/?3495 Summary: Starting with first city placed Project: Freeciv Submitted by: cazfi Submitted on: Thu 09 Aug 2012 10:32:46 PM EEST Category: None Priority: 5 - Normal Status: None Privacy: Public Assigned to: None Originator Email: Open/Closed: Open Discussion Lock: Any Planned Release: ___ Details: Lately I have encountered several ruleset-projects which would more or less need to start game with capital city already placed on map, either in addition to startunits or replacing them. Should we have some support in C-code (ruleset format) for this, or should it be implemented in ruleset's lua-script? (I think it should be doable with current scripting facilities, but have not tried) ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [patch #3495] Starting with first city placed
Follow-up Comment #1, patch #3495 (project freeciv): I used to insert in script.lua a function. function city_nation_swedish() local owner = find.player(0) local Stockholm = find.tile(208,93) create_city(owner, Stockholm, 'Stockholm') end function turn_cb(turn, year) if turn == 0 then city_nation_swedish() end end signal.connect('turn_started', 'turn_cb') Maybe insert coordinates of city in scenario file, under nation start position. r0=Swedish r0sx=208 r0sy=93 r0scity=Stockholm r0sx=??? r0sy=??? r0scity=Sundsvall ___ Reply to this item at: http://gna.org/patch/?3495 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev