wiki.sine.space | sinespace

Difference between revisions of "Scripting/SHost"

From wiki.sine.space
Jump to: navigation, search
(Members)
Line 6: Line 6:
 
{{ScriptFunction|SGameObject|ExecutingObject|{ get; }|Returns the SGameObject this script is attached to}}
 
{{ScriptFunction|SGameObject|ExecutingObject|{ get; }|Returns the SGameObject this script is attached to}}
 
{{ScriptFunction|string|Language|{ get; }|Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'}}
 
{{ScriptFunction|string|Language|{ get; }|Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'}}
 
+
{{ScriptFunction|void|StartCoroutine|(DynValue func);|Executes the specified function as a coroutine.|
 +
local function myCoroutine()
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;-- The yield statement is a special kind of return, that ensures that the function will continue from the line once the coroutine resumes.
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;-- Placing a float value inside of the yield will result in a delayed execution.
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;-- Example: coroutine.yield(0.5) will wait 0.5 seconds before continuing the execution of the coroutine.
 +
<br>
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;-- This will print the current players active time.
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(Space.Time);
 +
<br>
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;-- Execution of this coroutine will halted for 10 seconds.
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;coroutine.yield(10);
 +
<br>
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;-- This will print the current players active time, which will be 10 seconds greater then the previous as a result of the yield
 +
<br>&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(Space.Time);
 +
<br>end
 +
<br>
 +
<br>Space.Host.StartCoroutine(myCoroutine);
 +
<br>
 +
}}
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 18:56, 19 December 2017

The SHost class represents the scripting runtime.

Members

InvokeEvent

void InvokeEvent (string name);

Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.

No example provided yet


Stop

void Stop ();

Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well

No example provided yet


ExecutingObject

SGameObject ExecutingObject { get; }

Returns the SGameObject this script is attached to

No example provided yet


Language

string Language { get; }

Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'

No example provided yet


StartCoroutine

void StartCoroutine (DynValue func);

Executes the specified function as a coroutine.

local function myCoroutine()
    -- The yield statement is a special kind of return, that ensures that the function will continue from the line once the coroutine resumes.
    -- Placing a float value inside of the yield will result in a delayed execution.
    -- Example: coroutine.yield(0.5) will wait 0.5 seconds before continuing the execution of the coroutine.

    -- This will print the current players active time.
    Space.Log(Space.Time);

    -- Execution of this coroutine will halted for 10 seconds.
    coroutine.yield(10);

    -- This will print the current players active time, which will be 10 seconds greater then the previous as a result of the yield
    Space.Log(Space.Time);
end

Space.Host.StartCoroutine(myCoroutine);