1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/on_tick_schedule.lua

16 lines
453 B
Lua
Raw Normal View History

2019-03-03 03:38:29 +02:00
local event = require 'utils.event'
2019-03-17 19:19:40 +02:00
local function on_tick()
if not global.on_tick_schedule[game.tick] then return end
2019-03-03 03:38:29 +02:00
for _, schedule in pairs(global.on_tick_schedule[game.tick]) do
2019-03-17 19:19:40 +02:00
schedule.func(unpack(schedule.args))
end
2019-03-03 03:38:29 +02:00
global.on_tick_schedule[game.tick] = nil
end
2019-03-11 19:58:30 +02:00
local function on_init(event)
2019-03-17 19:19:40 +02:00
if not global.on_tick_schedule then global.on_tick_schedule = {} end
2019-03-03 03:38:29 +02:00
end
2019-03-11 19:58:30 +02:00
event.on_init(on_init)
2019-03-03 03:38:29 +02:00
event.add(defines.events.on_tick, on_tick)