- Home
- Downloads
-
Addons & Mods
Featured
World of Warcraft
5,104 Addons
-
Popular Downloads
- Top World of Warcraft Addons
- Top Minecraft Server Mods
- Top Rift Addons
- Top Skyrim Mods
- Top World of Tanks WoT Mods
- Top Starcraft II Maps
- Top Terraria Maps
- Top Runes of Magic Addons
- Top Warhammer Online Addons
- Top Age of Conan Addons
-
- Curse Client
- Premium
- News
- Giveaways
- Videos
- Forums
WaitTimer
- 0 Likes
- Runes of Magic
- 48 Monthly Downloads
- Supports: 4.0.2.2440
- 277 Total Downloads
- Updated 3/4/2012 7:23:19 AM
- Created 2/6/2012 6:29:21 AM
- 0 Favorites
- Project Site
- Comments
- Release Type: Release
- License: MIT License
- Newest File: v1.1
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 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.1
- added user data
Top Downloads
-
- WoWMap
- Map & Minimap
- 12,757 Monthly Downloads
-
- DailyNotes
- Tooltip and Quests & Leveling
- 7,185 Monthly Downloads
-
- pbInfo
- Quests & Leveling, Unit Frames, Tooltip, and Chat & Communication
- 5,487 Monthly Downloads
-
- Advanced AuctionHouse
- Tooltip and Auction & Economy
- 4,756 Monthly Downloads
-
- Advanced Quest Book
- Map & Minimap and Quests & Leveling
- 3,729 Monthly Downloads
Comments