VoidExpanse/scope-config: Difference between revisions

From AtomicTorchWiki
No edit summary
Line 2: Line 2:
[[Category:VoidExpanse/api_scopes]]
[[Category:VoidExpanse/api_scopes]]
</noinclude>
</noinclude>
= Config scope =
= Timer scope =
Used to get access to server variables from config file.
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|GetFlag|
{{Scripting_api|SetTimer|
* string: name|
* double: time_in_seconds
bool - whether the flag is set or not.|
* string: function_name
<pre style="margin:0px">var a = config.GetFlag("some_var");</pre> |
* object: args
Returns a boolean server flag value by name. Basically used to read server config options.
* 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|GetSetting|
* string: name|
object - a particular value of config.|
<pre style="margin:0px">var a = config.GetSetting("some_var");</pre>|
Returns a server variable value by name. Basically used to read server config options from script. Standard return types are string, int, float, boolean.
}}


{{Scripting_api|Wait|
{{Scripting_api|ClearTimer|
* int: time_ms|
* int: timer_id|
void |
void|
<pre style="margin:0px">config.Wait(1000); //wait for 1 second</pre>|
<pre style="margin:0px">timer.ClearTimer(5);</pre> |
Makes main thread to wait for specified time in milliseconds.
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
  • double: time_in_seconds
  • string: function_name
  • object: args
  • int: loops (0 - infinite)

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
  • int: timer_id

void

timer.ClearTimer(5);
Description

Removes timer with specified ID.