Page 1 of 1

mod on_init order?

Posted: Fri Oct 12, 2018 9:24 pm
by ownlyme
my wave defense mod seems to get loaded before the armored train mod, which causes bugs because my mod unlocks all technologies on init.
so since "w" should come after "a" i wonder what the on_init load order is, and if i can manipulate it somehow
otherwise i would like to know what force.research_all_technologies() exactly does, so i can just imitate that function.
thx

Re: mod init order?

Posted: Fri Oct 12, 2018 10:04 pm
by DaveMcW
lowercase 'w' comes before capital 'A'.

You can add it as an optional dependency in info.json to force your mod to load last:

Code: Select all

"dependencies": ["base", "? Armored-train"]

Re: mod on_init order?

Posted: Sat Oct 13, 2018 8:58 am
by ownlyme
this doesn't seem to affect the ingame load order (when starting a new scenario)
also both mods start with a capital letter..

maybe there is something else wrong, because the error is not indexing field '?', but instead comparing number with nil

this is the other mod's code:
on_init:
global.maxVehicleTurretTable = {}
for index, force in pairs(game.forces) do
global.maxVehicleTurretTable[index] = 1
end
global.maxTurretsUpperLimit = 1

on_research_finished:
if global.maxVehicleTurretTable[force] < global.maxTurretsUpperLimit

my mod sets the research of all forces to researched on init (but doesn't create a new force)

Re: mod on_init order?

Posted: Sat Oct 13, 2018 9:34 am
by eradicator
Are you sure you don't mean "wave defense scenario" when you say "wave defense mod"? Scenario on_init is always loaded before any mod on_init. For some "fun" discussion about the annoying interactions between on_research_finished, on_init and research_all_technologies see this old thread.

The problem the other mod seems to have is defining "global.maxTurretsUpperLimit = 1" outside of an event, which will simply be ignored, and thus when they try to compare it in on_research_finished it is nil. Though that should never work and not be triggered by your code. (but then again the example you gave is too short and unformatted to guess.)