VoidExpanse/scope-config: Difference between revisions
No edit summary |
|||
Line 2: | Line 2: | ||
[[Category:VoidExpanse/api_scopes]] | [[Category:VoidExpanse/api_scopes]] | ||
</noinclude> | </noinclude> | ||
= | = Timer scope = | ||
Used to | Used to create and manage timers - delayed events. Timers only works inside it's script, but | ||
they're persistent through savegames. | |||
'''Visibility:''' Global. | '''Visibility:''' Global. | ||
Line 9: | Line 10: | ||
== List of functions == | == List of functions == | ||
{{Scripting_api| | {{Scripting_api|SetTimer| | ||
* string: | * double: time_in_seconds | ||
* string: function_name | |||
<pre style="margin:0px">var | * object: args | ||
* int: loops (0 - infinite)| | |||
int - ID of created timer| | |||
<pre style="margin:0px">var timer = timer.SetTimer(5, "SomeFunction", {what_to_say: "hello"}, 1); | |||
function SomeFunction( args ) | |||
{ | |||
console.Print("I was told to say " + args.what_to_say); | |||
} | |||
</pre> | | |||
Creates a timed event, which will be executed after "time_in_seconds" interval. Can be infinite loop. | |||
}} | }} | ||
{{Scripting_api| | {{Scripting_api|ClearTimer| | ||
* int: | * int: timer_id| | ||
void | | void| | ||
<pre style="margin:0px"> | <pre style="margin:0px">timer.ClearTimer(5);</pre> | | ||
Removes timer with specified ID. | |||
}} | }} |
Revision as of 07:11, 18 February 2014
Timer scope
Used to create and manage timers - delayed events. Timers only works inside it's script, but they're persistent through savegames.
Visibility: Global.
List of functions
SetTimer | ||
---|---|---|
Arguments | Returns | Example |
|
int - ID of created timer |
var timer = timer.SetTimer(5, "SomeFunction", {what_to_say: "hello"}, 1); function SomeFunction( args ) { console.Print("I was told to say " + args.what_to_say); } |
Description | ||
Creates a timed event, which will be executed after "time_in_seconds" interval. Can be infinite loop. |
ClearTimer | ||
---|---|---|
Arguments | Returns | Example |
|
void |
timer.ClearTimer(5); |
Description | ||
Removes timer with specified ID. |