The problem is that mod A wants to call a remote method mod B expose when mod A receives the "on_player_created" event, but at this time mod B hasn't received the "on_player_created" yet, and is missing some initialization (i.e. setting some global["foo"]), causing the exposed method to fail as it relies on a completed initialization.
If I were to rename mod A to a name that starts with a letter later in the alphabet I'm betting it would work because then mod B would be done with event "on_player_created" by the time mod A handles the same event.
Currently I "solve" this with a hack in mod A:
Code: Select all
script.on_event(defines.events.on_tick, function(event)
remote.call("ModB", "doSomething", params)
script.on_event(defines.events.on_tick, nil) -- remove this event listener
end)
Is there a better way, am I missing something?
If not, should we design mods to emit a "mod_loaded" event that other mods can listen to and act accordingly?