mod on_init order?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

mod on_init order?

Post 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
Last edited by ownlyme on Sat Oct 13, 2018 8:44 am, edited 1 time in total.
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: mod init order?

Post 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"]

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: mod on_init order?

Post 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)
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: mod on_init order?

Post 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.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”