VoidExpanse/scope-script: Difference between revisions

From AtomicTorchWiki
(Created page with "= Config script = Used to get access to a specific script-related functions. '''Visibility:''' Global. == List of functions == {{Scripting_api|RestrictFunctionByTime| * str...")
 
Line 7: Line 7:


{{Scripting_api|RestrictFunctionByTime|
{{Scripting_api|RestrictFunctionByTime|
* string: name * float: seconds|
* string: name
* float: seconds|
void |
void |
<nowiki>script.RestrictFunctionByTime("some_function", 10);</nowiki> |
<nowiki>script.RestrictFunctionByTime("some_function", 10);</nowiki> |
Line 18: Line 19:


{{Scripting_api|RestrictFunctionFPS|
{{Scripting_api|RestrictFunctionFPS|
* string: name * int: fps|
* string: name
* int: fps|
void |
void |
<nowiki>script.RestrictFunctionFPS("some_function", 10);</nowiki> |
<nowiki>script.RestrictFunctionFPS("some_function", 10);</nowiki> |

Revision as of 02:35, 13 February 2014

Config script

Used to get access to a specific script-related functions.

Visibility: Global.

List of functions

RestrictFunctionByTime
Arguments Returns Example
  • string: name
  • float: seconds

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
  • string: name
  • int: fps

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

var time = script.GetSecondsMultiplier();

Description

Returns time since this function was called last time. Works properly only if function was restricted with RestrictFunctionByTime/RestrictFunctionFPS