1.5 KiB
1.5 KiB
Timers can call your functions delay and repeat it as often as you wish
setTime
sets the time the timer should wait after calling your function
Parameters:
numberthe time to delaynumberhow often it should be repeated -1 is infinite
Returns:
objectThe object
local mainFrame = basalt.createFrame()
local aTimer = mainFrame:addTimer()
aTimer:setTime(2)
<timer time="2" repeat="1"/>
start
Starts the timer
Returns:
objectThe object
local mainFrame = basalt.createFrame()
local aTimer = mainFrame:addTimer()
aTimer:setTime(2):start()
<timer time="2" start="true"/>
cancel
Cancels the timer
Returns:
objectThe object
local mainFrame = basalt.createFrame()
local aTimer = mainFrame:addTimer()
aTimer:setTime(2):start()
aTimer:cancel()
Events
onCall
onCall(self)
A custom event which gets triggered as soon as the current timer has finished
Here is a example on how to add a onCall event to your timer:
local basalt = require("Basalt")
local mainFrame = basalt.createFrame()
local aTimer = mainFrame:addTimer()
function call()
basalt.debug("The timer has finished!")
end
aTimer:onCall(call)
Here is also a example how this is done with xml:
local basalt = require("Basalt")
local mainFrame = basalt.createFrame()
basalt.setVariable("call", function()
basalt.debug("The timer has finished!")
end)
<progressbar onDone="call" />