Add timer function
This commit is contained in:
parent
60b5cb495c
commit
2c3dae2156
17
script.lua
17
script.lua
@ -96,6 +96,23 @@ end
|
|||||||
function onDamage(amount, source)
|
function onDamage(amount, source)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Timer (not mine lol) --
|
||||||
|
do
|
||||||
|
local timers = {}
|
||||||
|
function wait(ticks,next)
|
||||||
|
table.insert(timers, {t=world.getTime()+ticks,n=next})
|
||||||
|
end
|
||||||
|
function tick()
|
||||||
|
for key,timer in pairs(timers) do
|
||||||
|
if world.getTime() >= timer.t then
|
||||||
|
timer.n()
|
||||||
|
table.remove(timers,key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Tick function --
|
-- Tick function --
|
||||||
function tick()
|
function tick()
|
||||||
-- expression reset spaghetti code --
|
-- expression reset spaghetti code --
|
||||||
|
Loading…
x
Reference in New Issue
Block a user