Created
March 13, 2015 12:21
-
-
Save akshada-systematix/704aa2224c009115c17c to your computer and use it in GitHub Desktop.
Infinite Timer Loop to make function calls at different interval of time
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
--Infinite timer with different time interval | |
--Initialize timers | |
local timer_1, timer_2, timer_3 | |
function A() | |
print(“This is function A”) | |
if (timer_1) then | |
timer.cancel(timer_1) --cancelling 'timer_1' if exist | |
end | |
if (timer_3) then | |
timer.cancel(timer_3) --cancelling 'timer_3' if exist | |
end | |
timer_2 = timer.performWithDelay(500, B, 1) | |
end | |
function B() | |
print(“This is function B”) | |
if (timer_2) then | |
timer.cancel(timer_2) --cancelling 'timer_2' if exist | |
end | |
timer_3 = timer.performWithDelay(100, A, 1) | |
end | |
timer_1 = timer.performWithDelay(100, A, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment