___________________________________________________________________________________________________________________________
This small library provide an easy way to handle delays or pause in lua.
! All stuff is based on "OnUpdate events" so you can't use any Use-/Cast Item-/Spell stuff !
What it provides: a) delayed calls: start a timer which will execute code after a time period b) repeated loops: a) can also be used to repeatly call the code c) wait: pause a function
Function 'Wait' was renamed to 'Delay'. Plz change your code to keep compatible with future versions.
Renamed the base-addon name. So it's possible to use it without explicit linking it - even if you still should do it when releasing stuff based on it.
Delay / Fire & Forget calls
-- a delayed function call WaitTimer.Delay(5, function () DEFAULT_CHAT_FRAME:AddMessage("huhu") end) -- repeated call (single timer) WaitTimer.Delay(10, function () DEFAULT_CHAT_FRAME:AddMessage("wake up") return 10 end, "mytimer") -- NB: "mytimer" must be a unique name ... WaitTimer.Stop("mytimer") -- repeated call id = WaitTimer.Delay(10, function () DEFAULT_CHAT_FRAME:AddMessage("wake up") return 10 end) ... WaitTimer.Stop(id) -- with user data function MyTimer(data) DEFAULT_CHAT_FRAME:AddMessage(data) end WaitTimer.Delay(5, MyTimer, nil, "Hello World")
Pause / Function interrupt
WaitTimer.Call(worker) function worker() DEFAULT_CHAT_FRAME:AddMessage("ready") WaitTimer.CallWait(1) DEFAULT_CHAT_FRAME:AddMessage("set") WaitTimer.CallWait(1) DEFAULT_CHAT_FRAME:AddMessage("go") end
copy theses files to your addon or any subdirectory of it
Usually people will use a "lib" subdirectory
Add them at the beginning of your .toc file to make sure they get loaded.
local WaitTimer = LibStub("WaitTimer")
put it at the beginnig of your lua file where you want to use the WaitTimer.
timer_id = WaitTimer.Delay(seconds, function, id, data)
WaitTimer.Stop(id)
resttime= WaitTimer.Remaining(id)
WaitTimer.SetTime(id, delay)
WaitTimer.Call(fct, data)
WaitTimer.CallWait(time)
About Project
Created: November 16th 2023
Updated: November 16th 2023
Project ID: 65735
License: All Rights Reserved
__________________________________________
Game Versions:
1.01.03
1.01.03
1.01.03
1.01.03
1.01.03
__________________________________________
Flavors:
WoW Retail
__________________________________________
Categories
Companions
Battle
__________________________________________
Main File
November 16th 2023
__________________________________________
Recent File
November 16th 2023
__________________________________________
Members
__________________________________________
Report