96
edits
m |
m |
||
| Line 24: | Line 24: | ||
This example function works if the code above has been used: whenever you call the function, it checks whether its related loop table is already in Loops, if not then it creates one | This example function works if the code above has been used: whenever you call the function, it checks whether its related loop table is already in Loops, if not then it creates one; that loop's function will display a number that increases every X number of frames, and then the loop deletes itself after looping Y number of times. | ||
{{Collapse|1=<pre> | {{Collapse|1=<pre> | ||
--Usage: ExampleFun(10,100) counts upward every 10 frames and stops after it does that 100 times, etc | --Usage: ExampleFun(10,100) counts upward every 10 frames and stops after it does that 100 times, etc | ||
| Line 31: | Line 31: | ||
if not Loops["ExampleLoop"] then | if not Loops["ExampleLoop"] then | ||
Loops["ExampleLoop"] = { | Loops["ExampleLoop"] = { | ||
--initial persistent variables, reference in code with my.VariableName | |||
timer = X-1, | timer = X-1, | ||
delay = X, | delay = X, | ||
count = -1, | count = -1, | ||
limit = Y, | limit = Y, | ||
fun = function(my) | fun = function(my) --the looping code all goes in this function | ||
--checks if enough frames have passed | --checks if enough frames have passed | ||
my.timer = my.timer + 1 | my.timer = my.timer + 1 | ||