Hello!
This is a very cool idea for a mod! And very well written code for a first Factorio mod :D Just one small thing, it looks to be multiplayer unsafe due to your usage of global
, meaning it could cause desyncs. Most likely, everytime a player joins a MP game it will reset that player's global
while control.lua
is exectuted, even though some other player might have entries in their global.
Typically you only touch data that can change in runtime inside events, which includes the global
table. So something like:
local function init()
global.insert_on_tick = global.insert_on_tick or {}
global.pending_unit_tick = global.pending_unit_tick or {}
end
script.on_init(init)
script.on_configuration_changed(init)
Also, a little side note, your on_entity_built might crash if the entity wasn't built from an item. The docs also show that item
is optional.