mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Created Timer (markdown)
1 parent
91a01a04b8
commit
66507c690a
1 file changed
+52
+52
@@ -0,0 +1,52 @@
|
|||||||
|
The Timer module lets you execute pieces of script with a delay and optionally multiple times.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
* [SetTimer](https://github.com/SpoinkyNL/Artemis/wiki/timer#settimer)
|
||||||
|
* [StopTimer](https://github.com/SpoinkyNL/Artemis/wiki/timer#stoptimer)
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
### SetTimer
|
||||||
|
Creates and starts a timer using the given variables.
|
||||||
|
#### Syntax:
|
||||||
|
```lua
|
||||||
|
timer SetTimer(function function, int interval, int timesToExecute, [params]);
|
||||||
|
```
|
||||||
|
##### Required arguments
|
||||||
|
- **function:** A LUA function to be called each time the timer ticks
|
||||||
|
- **interval:** The amount of time in milliseconds between each tick
|
||||||
|
- **timesToExecute:** The amount of times to run the function, use **0** for infinite
|
||||||
|
|
||||||
|
##### Optional arguments
|
||||||
|
**Note:** The arguments between [brackets] are optional and you can leave them out.
|
||||||
|
- **params:** Paramaters you wish to pass to the function the timer will call on each tick
|
||||||
|
|
||||||
|
#### Example:
|
||||||
|
```lua
|
||||||
|
-- Simple example without passing arguments
|
||||||
|
local helloAmount = 1;
|
||||||
|
function timedHello()
|
||||||
|
print("Hello! " .. helloAmount);
|
||||||
|
helloAmount = helloAmount + 1;
|
||||||
|
end
|
||||||
|
Timer.SetTimer(timedHello, 1000, 5);
|
||||||
|
|
||||||
|
-- Example with passing arguments
|
||||||
|
local printAmount = 1;
|
||||||
|
function timedPrint(text)
|
||||||
|
print(text .. printAmount);
|
||||||
|
printAmount = printAmount + 1;
|
||||||
|
end
|
||||||
|
Timer.SetTimer(timedPrint, 1000, 5, "Hello! ");
|
||||||
|
```
|
||||||
|
---
|
||||||
|
### StopTimer
|
||||||
|
TODO
|
||||||
|
#### Syntax:
|
||||||
|
```lua
|
||||||
|
TODO
|
||||||
|
```
|
||||||
|
#### Example:
|
||||||
|
```lua
|
||||||
|
TODO
|
||||||
|
```
|
||||||
|
---
|
||||||
Reference in new issue
Block a user