I have some catching-up to do in this topic!
This is the Lua script included in the scenario MiniMap Islands, shared at this link: https://forum.freeciv.org/f/viewtopic.p ... 04#p110004
Creating this Lua script in Freeciv 2.6.4 included a few frustrations...
Lua has no way to determine the startpos values included in the scenario file's [map] section. If the normal process of allowing aifill to create all players initially is used then it is fairly simple to get a tile on which a player's unit is standing at the beginning of turn 0 -- a prior script LateArrivalStartunits does just that. Also if startcity is enabled then it is very easy to get the tile where each tribe's startcity is built. But in this scenario I wanted to limit the computer-controlled tribes to using only island nations -- so aifill had to be disabled since it can't be restricted to solely island nations, and therefore there are no "AI" tribe startunits at the startpos tiles listed in the scenario. And there are no startcities for the computer-controlled tribes since the players don't yet exist when the game begins. So I had to duplicate the startpos values included in the scenario, by adding them manually in the script.
Since aifill is disabled, each of computer-controlled tribes had to be created manually, and the first bit of data needed is "leader name" -- which Lua can't get despite that the names are in the nation's ruleset files. So I used as leader names, Curly, Larry, and Moe instead.
Lua also can't determine which nations are or aren't island nations, so I had to do that manually by grep'ing for "island" in the nations files, sorting out those that aren't actually island nations, correcting the names to exactly match the nation ruleset names, and including the final list in the script itself. A flag for nation geographical type (island, coastal, inland or land-locked) in the ruleset files might be helpful.
After creating each player, the player's startcity must be manually created, and the startunits must be manually created.
All that just to limit nations to island nations. But it works and if it helps someone trying to make a more serious island based scenario, then I'm happy.
This is the Lua script included in the scenario MiniMap Islands, shared at this link: https://forum.freeciv.org/f/viewtopic.p ... 04#p110004
Code:
o = "\n\n[c fg=\"#0000ff\"][ b ]Welcome to MiniMap Islands[ /b ][ /c ]" .."[c fg=\"#ff0000\"][ b ]\n\n\n" .."Select an island nation for your tribe via right-click\n" .. "on the player shown near the top of this window. Then\n" .."select 'Pick Nation' in the pop-up list. Click the 'All'\n" .."button for all nations and select an island nation\n" .."such as Hawaiian.\n\n[ /b ][ /c ]"notify.event( nil, nil, E.CHAT_MSG, o )function s_setup()if not _G.setupDone thenlocal tileIDs = { 34, 45, 210, 221 }local island_nations = { "Acehnese", "Ainu", "Alander", "Aleut", "Antiguan and Barbudan", "Antillean", "Bahamian", "Bahraini", "Barbadian", "Cape Verdean", "Chinese", "Chumash", "Comorian", "Cretan", "Cuban", "Cypriot", "Dominican", "Dominicano", "Ecuadorian", "Equatoguinean", "Faroese", "Fijian", "Formosan", "Greenlander", "Grenadian", "Guanche", "Icelandic", "Illyrian", "Indonesian", "Jamaican", "Kiribati", "Malagasy", "Maldivian", "Maltese", "Manx", "Maori", "Marshallese", "Mauritian", "Moluccan", "Nauruan", "Nestorian", "Newfoundland", "New Zealand", "Nuu-chah-nulth", "Papuan", "Papua New Guinean", "Polynesian", "Puerto Rican", "Rapa Nui", "Saint Lucian", "Samoan", "Santomean", "Sardinian", "Seychellois", "Sicilian", "Sinhalese", "Solomon Islander", "Tahitian", "Taino", "Taiwanese", "Tongan", "Trinidadian and Tobagonian", "Turkish Cypriot", "Vanuatuan", "Venetian", "Vincentian", "West Indian" }local rulerNames = { "Curly", "Larry", "Moe" }for i = 1, 3, 1 dotribe = find.nation_type( island_nations[ random( 1, #island_nations ) ] )if tribe thenplayer = edit.create_player( rulerNames[ i ], tribe, nil )for j = 1, 4, 1 dotile = find.tile( tileIDs[ j ] )if not tile:city() thencity = edit.create_city( player, tile, nil )local startunits = server.setting.get( "startunits" )for i = 1, #startunits dolocal c = startunits:sub(i,i)if c == "c" then unit = find.unit_type( "Settlers" )elseif c == "f" then unit = find.unit_type( "Trireme" )elseif c == "d" then unit = find.unit_type( "Warriors" )endedit.create_unit_full( player, tile, unit, 0, nil, 0, -1, nil )endbreakendendendendfor player in players_iterate() doedit.give_tech( player, find.tech_type( "Map Making" ), 0, nil, nil )end_G.setupDone = trueendendsignal.connect( "turn_started", "s_setup" )
Lua has no way to determine the startpos values included in the scenario file's [map] section. If the normal process of allowing aifill to create all players initially is used then it is fairly simple to get a tile on which a player's unit is standing at the beginning of turn 0 -- a prior script LateArrivalStartunits does just that. Also if startcity is enabled then it is very easy to get the tile where each tribe's startcity is built. But in this scenario I wanted to limit the computer-controlled tribes to using only island nations -- so aifill had to be disabled since it can't be restricted to solely island nations, and therefore there are no "AI" tribe startunits at the startpos tiles listed in the scenario. And there are no startcities for the computer-controlled tribes since the players don't yet exist when the game begins. So I had to duplicate the startpos values included in the scenario, by adding them manually in the script.
Since aifill is disabled, each of computer-controlled tribes had to be created manually, and the first bit of data needed is "leader name" -- which Lua can't get despite that the names are in the nation's ruleset files. So I used as leader names, Curly, Larry, and Moe instead.
Lua also can't determine which nations are or aren't island nations, so I had to do that manually by grep'ing for "island" in the nations files, sorting out those that aren't actually island nations, correcting the names to exactly match the nation ruleset names, and including the final list in the script itself. A flag for nation geographical type (island, coastal, inland or land-locked) in the ruleset files might be helpful.
After creating each player, the player's startcity must be manually created, and the startunits must be manually created.
All that just to limit nations to island nations. But it works and if it helps someone trying to make a more serious island based scenario, then I'm happy.
Statistics: Posted by Molo_Parko — Fri Nov 08, 2024 7:48 pm