-
-
Save serjoscha87/917d4c8756d1ec90ce8f to your computer and use it in GitHub Desktop.
ws lua timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyAddon:Init() | |
Apollo.RegisterTimerHandler("test_timer", "MyTimerHandlerFunc", self) | |
end | |
function MyAddon:OnStartTestTimerButtonClick() -- this shall be a button click handler... just for a concrete example.. do not further care about it | |
Apollo.CreateTimer("test_timer", 1.0, true) -- recurring timer, running every second | |
end | |
local i=0 | |
function MyAddon:MyTimerHandlerFunc() | |
i = i+1 | |
if(i==10) then | |
-- Stop the timer! | |
Apollo.StopTimer("test_timer") -- THIS DOES NOT WORK. THIS SEEMS TO BE A BUG IN WS LUA API | |
-- SOLUTION FOR STOPPING THE TIMER: | |
Apollo.CreateTimer("test_timer", 1.0, false) -- he we overwrite the timer and tell that we not want it to be recurring | |
Apollo.StopTimer("test_timer") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment