Project Zomboid

Project Zomboid

99 ratings
Lua Timers
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
8.572 KB
15 Oct, 2022 @ 12:33am
16 Feb @ 1:37pm
3 Change Notes ( view )

Subscribe to download
Lua Timers

Description
THIS MOD IS API AND LITERALLY DON'T CHANGE ANYTHING

Explanation: https://pastebin.com/z3JmKBtL

Available functions:
timer:Simple(delay, function)
timer:Create(name, delay, repetitions, function)
timer:Remove(name)
timer:Exists(name)
timer:Start(name) - fully restarts (recreates) the timer
timer:Pause(name)
timer:UnPause(name)/timer:Resume(name)
timer:Toggle(name)
timer:TimeLeft(name)
timer:NextTimeLeft(name)
timer:RepsLeft(name)

Workshop ID: 2875394066
Mod ID: LuaTimers
26 Comments
N0wh3re 21 Aug @ 2:10pm 
Hello, I'm new to LUA and studying LUA now. I'm working with meds with cool effects for my first mod. anyway, I saw your mod and worked very well without any problem! but it seems following real os time instead game time.
this is a kind of weird question that asking to you tho, do you know where can i learn about wait function of lua? or do you know some similllar mods that i can study?
Sorry but I have no one to ask about this. i hope i didn't bother you. have a good day!
RJ_RayJay 16 Feb @ 2:04pm 
@𝚅𝚒𝚜𝚑𝚗𝚢𝚊 No problem, I'm glad it's fixed now (better late than never xD)
𝚅𝚒𝚜𝚑𝚗𝚢𝚊  [author] 16 Feb @ 1:39pm 
@RJ_RayJay LOL, you right, I didn't upload it for for almost 2 years. how.. thanks for your notice about that, now it's correct :spiffo:
RJ_RayJay 16 Feb @ 11:03am 
@𝚅𝚒𝚜𝚑𝚗𝚢𝚊 I don't see that in the files on my end for this mod, do you have an updated version?
Here's a picture of what I see: {LINK REMOVED}
𝚅𝚒𝚜𝚑𝚗𝚢𝚊  [author] 16 Feb @ 5:38am 
@RJ_RayJay repetitions check only if `not v.Infinity` (line 58)
RJ_RayJay 15 Feb @ 12:46pm 
@𝚅𝚒𝚜𝚑𝚗𝚢𝚊 Yes that's right, I set the repetitions to 0 to run the timer indefinitely but it would only run once in my testing. In your code at line 59 for lua_timers.lua it defines the following:

if v.Repetitions <= 0 then
timer.Timers[k] = nil
end

Since it checks if repetitions is less than or equal to 0, it will remove the timer.
𝚅𝚒𝚜𝚑𝚗𝚢𝚊  [author] 14 Feb @ 3:42pm 
@RJ_RayJay `Infinity = repetitions == 0`
RJ_RayJay 14 Feb @ 12:07pm 
I believe the infinite repetitions does not work. I checked your code and if the repetitions is less than or equal to 0 (which is what it should be for infinite reps) it will remove the timer. Unless I'm missing something in my analysis?
Watermelon 26 Jul, 2023 @ 6:09pm 
This is so fucking useful it saved me so much time with my mod.
𝚅𝚒𝚜𝚑𝚗𝚢𝚊  [author] 26 Jun, 2023 @ 2:23am 
@Tomaro yup :spiffo: