From 66507c690a4ebb57cec397b9d9fe3582f9b51c66 Mon Sep 17 00:00:00 2001 From: Robert Beekman Date: Tue, 27 Dec 2016 13:13:52 +0100 Subject: [PATCH] Created Timer (markdown) --- Timer.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Timer.md diff --git a/Timer.md b/Timer.md new file mode 100644 index 0000000..911d385 --- /dev/null +++ b/Timer.md @@ -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 +``` +--- \ No newline at end of file