From 2c3dae2156da155bd9e19b5d4e1839464f3156ac Mon Sep 17 00:00:00 2001 From: NullBite <me@nullbite.com> Date: Tue, 15 Mar 2022 22:54:56 -0400 Subject: [PATCH] Add timer function --- script.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/script.lua b/script.lua index 17eaadd..fa74f11 100644 --- a/script.lua +++ b/script.lua @@ -96,6 +96,23 @@ end function onDamage(amount, source) 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 -- function tick() -- expression reset spaghetti code --