VoidExpanse/scope-script: Difference between revisions
Atomic-admin (talk | contribs) No edit summary |
|||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
= | <noinclude> | ||
[[Category:VoidExpanse/api_scopes]] | |||
</noinclude> | |||
= Scope script = | |||
Used to get access to a specific script-related functions. | Used to get access to a specific script-related functions. | ||
| Line 10: | Line 14: | ||
* float: seconds| | * float: seconds| | ||
void | | void | | ||
< | <pre style="margin:0px;">script.RestrictFunctionByTime("some_function", 10);</pre> | | ||
It can be useful, when you want to subscribe to every-frame event, like OnEnterFrame, | It can be useful, when you want to subscribe to every-frame event, like OnEnterFrame, | ||
but you don't want your function to be called every frame. In this case one of possible | but you don't want your function to be called every frame. In this case one of possible | ||
| Line 22: | Line 26: | ||
* int: fps| | * int: fps| | ||
void | | void | | ||
< | <pre style="margin:0px;">script.RestrictFunctionFPS("some_function", 10);</pre> | | ||
It can be useful, when you want to subscribe to every-frame event, like OnEnterFrame, | It can be useful, when you want to subscribe to every-frame event, like OnEnterFrame, | ||
but you don't want your function to be called every frame. In this case one of possible | but you don't want your function to be called every frame. In this case one of possible | ||
| Line 31: | Line 35: | ||
{{Scripting_api|GetSecondsMultiplier| | {{Scripting_api|GetSecondsMultiplier| | ||
| | void| | ||
Double| | |||
< | <pre style="margin:0px;">var time = script.GetSecondsMultiplier();</pre> | | ||
Returns time since this function was called last time. Works properly only if function | Returns time since this function was called last time. Works properly only if function | ||
was restricted with RestrictFunctionByTime/RestrictFunctionFPS | was restricted with RestrictFunctionByTime/RestrictFunctionFPS | ||
}} | }} | ||
Latest revision as of 04:05, 13 February 2014
Scope script
Used to get access to a specific script-related functions.
Visibility: Global.
List of functions
| RestrictFunctionByTime | ||
|---|---|---|
| Arguments | Returns | Example |
|
void |
script.RestrictFunctionByTime("some_function", 10);
|
| Description | ||
|
It can be useful, when you want to subscribe to every-frame event, like OnEnterFrame, but you don't want your function to be called every frame. In this case one of possible solutions would be to use function pair : RestrictFunctionByTime/RestrictFunctionFPS. In such functions, in case you need an interval since it was last called, you'd call script.GetSecondsMultiplier instead of standard game.GetSecondsMultipler. | ||
| RestrictFunctionFPS | ||
|---|---|---|
| Arguments | Returns | Example |
|
void |
script.RestrictFunctionFPS("some_function", 10);
|
| Description | ||
|
It can be useful, when you want to subscribe to every-frame event, like OnEnterFrame, but you don't want your function to be called every frame. In this case one of possible solutions would be to use function pair : RestrictFunctionByTime/RestrictFunctionFPS. In such functions, in case you need an interval since it was last called, you'd call script.GetSecondsMultiplier instead of standard game.GetSecondsMultipler. | ||
| GetSecondsMultiplier | ||
|---|---|---|
| Arguments | Returns | Example |
|
void |
Double |
var time = script.GetSecondsMultiplier(); |
| Description | ||
|
Returns time since this function was called last time. Works properly only if function was restricted with RestrictFunctionByTime/RestrictFunctionFPS | ||