Compare commits

...

2 Commits

Author SHA1 Message Date
083d8319eb
Fix sharedstate.commit() 2023-06-24 23:24:45 -04:00
bf1b2d4f7c
Add documentation to timers.lua 2023-06-24 23:24:11 -04:00
2 changed files with 12 additions and 3 deletions

View File

@ -208,9 +208,8 @@ function sharedstate.commit()
-- send_queue[key]=t
-- end
pings.sharedstate_unpack(state_queue)
state_queue={}
pings.sharedstate_recv_table(state_queue)
sharedstate.clear()
end
--- Clear a value from the shared state queue

View File

@ -4,6 +4,10 @@
timers={}
do
local timers = {}
--- Wait
--Wait a certain number of ticks and execute a function.
---@param ticks integer Number of ticks to wait
---@param next function Callback to run
function wait(ticks,next)
table.insert(timers, {t=world.getTime()+ticks,n=next})
end
@ -24,6 +28,12 @@ timers.wait=wait
-- if timer is armed twice before expiring it will only be called once) --
do
local timers = {}
--- Wait
--Wait a certain number of ticks and execute a function. Store the timer with a name so that
--it can be overwritten.
---@param ticks integer Number of ticks to wait
---@param next function Callback to run
---@param name function Name of callback
function namedWait(ticks, next, name)
-- main difference, this will overwrite an existing timer with
-- the same name