- Home
- Downloads
-
Addons & Mods
Featured
World of Warcraft
6,100 Addons
-
Popular Downloads
- Top World of Warcraft Addons
- Top Minecraft Server Mods
- Top Rift Addons
- Top Skyrim Mods
- Top World of Tanks Skins
- Top StarCraft II Maps
- Top Terraria Maps
- Top Runes of Magic Addons
- Top Warhammer Online Addons
- Top The Secret World Mods
- Top Age of Conan Addons
-
- Curse Client
- Premium
- News
- Giveaways
- Forums
- Store
WaitTimer
- 0 Likes
- Runes of Magic
- 14 Monthly Downloads
- Supports: 5.0.1
- 717 Total Downloads
- Updated 10/16/2012
- Created 02/06/2012
- 0 Favorites
- Project Site
- Comments
- Release Type: Release
- License: MIT License
- Newest File: v1.5
About WaitTimer
This small library provides an easy way to generate timed events.
You can setup a delayed or repeated function call without messing around with a dummy frame and OnUpdate events.
Example:
-- a delayed function call WaitTimer.Wait(5, function () DEFAULT_CHAT_FRAME:AddMessage("huhu") end) -- repeated call (single timer) WaitTimer.Wait(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.Wait(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.Wait(5, MyTimer, nil, "Hello World")
Setup:
copy theses files to your addon or any subdirectory of it
- LibStub.lua
- WaitTimer.lua
Usually people will use a "lib" subdirectory
Add them at the beginning of your .toc file to make sure they get loaded.
Init:
local WaitTimer = LibStub("WaitTimer")
put it at the beginnig of your lua file where you want to use the WaitTimer.
Usage:
timer_id = WaitTimer.Wait(seconds, function, id, data)
- seconds= how long to wait
- function= will be called when time is elapsed
if the function returns a value, this value is used as new wait_time. - id= (optional) a fixed timer id If another timer with the same ID exists it will be replaced
- data= (optional) will be passed to the function call
- timer_id= id which can be used in the other functions It's equal "id" when it was provided
WaitTimer.Stop(id)
- stops the timer without calling the function
waittime = WaitTimer.Remaining(id)
- return remaining seconds or nil
WaitTimer.SetTime(id, delay)
- reset the wait time
- if <delay> is ommited the function will be triggert on next update
v1.5
- improved error checking
- "Wait" will reset fct,data when id is in use
Top Downloads
-
- WoWMap
- Map & Minimap
- 10,264 Monthly Downloads
-
- CharPlan
- Bags & Inventory
- 5,362 Monthly Downloads
-
- WoWMap - POI
- Artwork and Map & Minimap
- 3,667 Monthly Downloads
-
- Advanced AuctionHouse
- Tooltip and Auction & Economy
- 3,129 Monthly Downloads
-
- pbInfo
- Quests & Leveling, Unit Frames, Tooltip, and Chat & Communication
- 2,954 Monthly Downloads
Comments