Last active
February 19, 2025 16:47
-
-
Save bukowa/91b5e40c8b8a72270c34f987d96d2bd9 to your computer and use it in GitHub Desktop.
rebelion rome2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Helper function to get the faction list from the game model | |
function getFactionList() | |
return scripting.game_interface:model():world():faction_list() | |
end | |
-- Helper function to get the region list from a faction | |
function getRegionList(faction) | |
return faction:region_list() | |
end | |
-- Helper function to iterate over a faction list | |
function iterateFactionList(factionList, callback) | |
for i = 0, factionList:num_items() - 1 do | |
local faction = factionList:item_at(i) | |
callback(faction) | |
end | |
end | |
-- Helper function to iterate over a region list of a faction | |
function iterateRegionList(regionList, callback) | |
for i = 0, regionList:num_items() - 1 do | |
local region = regionList:item_at(i) | |
callback(region) | |
end | |
end | |
-- Helper function to trigger a rebellion in a region | |
function triggerRebellionInRegion(region, unitList) | |
scripting.game_interface:force_rebellion_in_region(region, 10, unitList, 0, 0, true) | |
end | |
-- Main function that handles the settlement selection logic | |
scripting.AddEventCallBack('SettlementSelected', function(context) | |
-- Get the list of factions | |
local factionList = getFactionList() | |
-- Iterate over all factions | |
iterateFactionList(factionList, function(faction) | |
local regionList = getRegionList(faction) | |
-- Iterate over all regions of the current faction | |
iterateRegionList(regionList, function(region) | |
local regionName = region:name() | |
-- Trigger a rebellion in the region | |
triggerRebellionInRegion(regionName, "Rom_Equites_Late_Allied") | |
end) | |
end) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment