1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Updated Timer (markdown)

Robert Beekman 2017-09-12 14:23:12 +02:00
parent 61ae8930d0
commit b019eaf301

@ -9,7 +9,7 @@ The Timer module lets you execute pieces of script with a delay and optionally m
Creates and starts a timer using the given variables.
#### Syntax:
```lua
timer SetTimer(function function, int interval, int timesToExecute, [params]);
timer SetTimer(function function, int interval, int timesToExecute, [params])
```
##### Required arguments
- **function:** A LUA function to be called each time the timer ticks
@ -23,38 +23,38 @@ timer SetTimer(function function, int interval, int timesToExecute, [params]);
#### Example:
```lua
-- Simple example without passing arguments
local helloAmount = 1;
local helloAmount = 1
function timedHello()
print("Hello! " .. helloAmount);
helloAmount = helloAmount + 1;
print("Hello! " .. helloAmount)
helloAmount = helloAmount + 1
end
Timer.SetTimer(timedHello, 1000, 5);
Timer.SetTimer(timedHello, 1000, 5)
-- Example with passing arguments
local printAmount = 1;
local printAmount = 1
function timedPrint(text)
print(text .. printAmount);
printAmount = printAmount + 1;
print(text .. printAmount)
printAmount = printAmount + 1
end
Timer.SetTimer(timedPrint, 1000, 5, "Hello! ");
Timer.SetTimer(timedPrint, 1000, 5, "Hello! ")
```
---
### RemoveTimer
Removes an existing timer.
```lua
RemoveTimer(timer timer);
RemoveTimer(timer timer)
```
##### Required arguments
- **timer:** The timer to remove
#### Example:
```lua
local helloTimer;
local helloTimer
function timedHello()
print("Hello!");
-- Stop the timer after running once
Timer.RemoveTimer(helloTimer);
print("Hello!")
-- Stop the timer after running once
Timer.RemoveTimer(helloTimer)
end
helloTimer = Timer.SetTimer(timedHello, 1000, 5);
helloTimer = Timer.SetTimer(timedHello, 1000, 5)
```
---