Code: Select all
script.on_event(defines.events.on_tick, function(event)
run_every_5_seconds
if something do
do stuff
wait 1 tick
do more stuff
end
wait 1 tick
do more stuff
etc.
end
end)
Code: Select all
script.on_event(defines.events.on_tick, function(event)
run_every_5_seconds
if something do
do stuff
wait 1 tick
do more stuff
end
wait 1 tick
do more stuff
etc.
end
end)
Code: Select all
local mycoroutine = coroutine.create (function ()
run_every_5_seconds
if something do
do stuff
coroutine.yield()
do more stuff
end
coroutine.yield()
do more stuff
etc.
end
end )
script.on_event(defines.events.on_tick, function(event)
coroutine.resume(mycoroutine)
end)
Oh! For now I found a way to make the code much less performance heavy, so this isn't needed. But thanks anyway!