function tick() printf( "tick @ %i", game.time() ) end function tick_nil() printf( "tick_nil @ %i", game.time() ) end function tick_act() printf( "tick_act @ %i", game.time() ) local event local thread = {} local now = game.time() for event in db.storage[db.storage[db.actor:id()].timed_events do if event.time <= now then local index = #thread+1 local thread[index] = coroutine.create( event.func ) coroutine.resume( thread[index], unpack( event.args ) ) event = nil end end if #(db.storage[db.storage[db.actor:id()].timed_events) == 0 then tick = tick_nil() end printf( "tick_act @ %i completed", game.time() ) end function register_event( atime, afunc, ... ) printf( "register_event @ %i completed", game.time() ) if tick == tick_nil then tick = tick_act end eventc = #(db.storage[db.storage[db.actor:id()].timed_events) db.storage[db.storage[db.actor:id()].timed_events[eventc+1] = { time = atime, func = afunc, args = { ... } } printf( "register_event @ %i completed", game.time() ) end