I'm trying to write a code in control for do a think like this:
- Game call an event different from on_tick, let's call this event A
- A call is associated to a function that put some values in a global table, like global.B
- Let's call on_tick each 60 tick and take one item from global.B do something and wait.
Code: Select all
{
...
{entity.surface, entity.position}
...
}
Code: Select all
function doThings(event)
game.print(#global.B)
if event.tick % 60 == 0 and #global.B> 0 then
local i, entry = next(global.B)
if entry then
doSomething(entry)
table.remove(global.B, i)
end
end
end
...
script.event(...on_tick, doThings)
When the game call 2 event in control of one mod, is a sequential execution? Can be some call ignored if too much? There's a limit on the space taken in global by one mod?
Any suggestion?