Skip to content

Instantly share code, notes, and snippets.

@serjoscha87
Created November 13, 2015 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serjoscha87/917d4c8756d1ec90ce8f to your computer and use it in GitHub Desktop.
Save serjoscha87/917d4c8756d1ec90ce8f to your computer and use it in GitHub Desktop.
ws lua timer
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