My control.lua file follows the following schematic:
Code: Select all
require "util"
require "story"
require "defines"
-- Table Declarations --
glob.blueprints = {} -- mod-Namespace
glob.blueprints.XXX
...
---------------------------------
game.onit(function()
game.player.character.insert{name="iron-plate", count=8}
...
end)
game.onevent(defines.events.onbuiltentity, function(event)
...
end)
...
So for example I start a new game, place 2 chest + 2 markers to copy them. Normally I should receive a Msg that tells me that 2 entities are copied.
But in approx 50% of my tests I received a Msg that tells me 0 entities are copied.
BUT if I exit the game completely or only the current freeplay, not factorio at all and start a new game I have a 50% chance again that it the mod will work correctly then..
Also this behaviour would explain why my treemod sometimes work and sometimes not...
I tried to place the table-declarations in the onInit as well, but same behaviour.
EDIT: I also tested it with "game.player.print(glob.blueprints)
When everything works fine I got an error " string expected, got table". That is what I expected, but when I do the same where the mod ar not working correctly I receive "string expected, got nil", that is why I think that the tables are not initialized correctly every time.