Sinespace Client  2023.2.17543
Client-side scripting for Sinespace
SineSpace.Scripting.Scene.SHost Class Reference

Public Member Functions

 SHost (SScript sScript)
 
void InvokeEvent (string name)
 Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in. More...
 
void Stop ()
 Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well More...
 
void InvokeDelayed (Closure c, float delay)
 Invoke the closure after the delayed time More...
 
void StartCoroutine (DynValue value, DynValue parameter=default(DynValue), string name=null)
 Executes the specified function as a coroutine. More...
 
void StartCoroutine (string value, DynValue parameter=default(DynValue), string name=null)
 
bool ReferenceExists (string name)
 Return true when the reference object exists. More...
 
bool ReferenceExistsAndNotEmpty (string name)
 Return true when the reference object exists and is not empty More...
 
SGameObject GetReference (string name)
 Return SGameObject which attach to the reference with the correct name. More...
 
void Evaluate (string script)
 Evaluates and returns arbitrary Lua scripts. Only availible on white label grids. More...
 

Properties

SGameObject ExecutingObject [get]
 Returns the SGameObject this script is attached to More...
 
string Language [get]
 Returns the English name for the user’s language, e.g., 'English', 'French', 'Chinese' More...
 

Constructor & Destructor Documentation

◆ SHost()

SineSpace.Scripting.Scene.SHost.SHost ( SScript  sScript)

Member Function Documentation

◆ Evaluate()

void SineSpace.Scripting.Scene.SHost.Evaluate ( string  script)

Evaluates and returns arbitrary Lua scripts. Only availible on white label grids.

Parameters
script

◆ GetReference()

SGameObject SineSpace.Scripting.Scene.SHost.GetReference ( string  name)

Return SGameObject which attach to the reference with the correct name.

Parameters
nameName of reference
local obj=Space.Host.GetReference("Obj")
Space.Log(obj==nil)
–print "true" if you didn't set the object named "OBJ" to the Object References or attach
the reference to "OBJ"

◆ InvokeDelayed()

void SineSpace.Scripting.Scene.SHost.InvokeDelayed ( Closure  c,
float  delay 
)

Invoke the closure after the delayed time

Parameters
cThe closure you want to call
delayDelayed time
Space.Host.InvokeDelayed(function()
Space.Log("InvokeDelayed")
end,5)
–print "InvokeDelayed" after 5 seconds.

◆ InvokeEvent()

void SineSpace.Scripting.Scene.SHost.InvokeEvent ( string  name)

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

Parameters
nameEvent name
function InvokeExample()
Space.Log("Invoke Event")
end
–Attach the upon function to Scripting Runtime/Unity Interfaces/Events, Named "InvokeExample"
Space.Host.InvokeEvent("InvokeExample")
–print "Invoke Event" to the console

◆ ReferenceExists()

bool SineSpace.Scripting.Scene.SHost.ReferenceExists ( string  name)

Return true when the reference object exists.

Parameters
nameName of reference object
Space.Log(Space.Host.ReferenceExists("OBJ"))
–print "false" to console if didn't set the object named "OBJ" to the Object References

◆ ReferenceExistsAndNotEmpty()

bool SineSpace.Scripting.Scene.SHost.ReferenceExistsAndNotEmpty ( string  name)

Return true when the reference object exists and is not empty

Parameters
nameName of reference object
Returns
Space.Log(Space.Host.ReferenceExistsAndNotEmpty("obj"))
–print "false" to console if didn't set the object named "obj" to the Object References
or attach the reference to "OBJ"

◆ StartCoroutine() [1/2]

void SineSpace.Scripting.Scene.SHost.StartCoroutine ( DynValue  value,
DynValue  parameter = default(DynValue),
string  name = null 
)

Executes the specified function as a coroutine.

Parameters
valueFunction
parameterResume time parameter
nameFunction name
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 player’s active time.
Space.Log(Space.Time);
– Execution of this coroutine will be halted for 10 seconds.
coroutine.yield(10);
– This will print the current players active time, which will be 10 seconds greater
than the previous as a result of the yield
Space.Log(Space.Time);
end
Space.Host.StartCoroutine(myCoroutine);

◆ StartCoroutine() [2/2]

void SineSpace.Scripting.Scene.SHost.StartCoroutine ( string  value,
DynValue  parameter = default(DynValue),
string  name = null 
)

◆ Stop()

void SineSpace.Scripting.Scene.SHost.Stop ( )

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

local trans=Space.Host.ExecutingObject
trans.SubscribeToEvents()
function Running()
Space.Log("Running")
end
trans.OnUpdate(Running)
Space.Host.InvokeDelayed(function()
Space.Log("Stop")
Space.Host.Stop()
end,5)
–After print the "Stop","Running" won't display anymore.

Property Documentation

◆ ExecutingObject

SGameObject SineSpace.Scripting.Scene.SHost.ExecutingObject
get

Returns the SGameObject this script is attached to

local obj=Space.Host.ExecutingObject
Space.Log(obj.Name)

◆ Language

string SineSpace.Scripting.Scene.SHost.Language
get

Returns the English name for the user’s language, e.g., 'English', 'French', 'Chinese'

Space.Log(Space.Host.Language)
–print current system language in English.
SineSpace.Scripting.Scene.SHost.InvokeDelayed
void InvokeDelayed(Closure c, float delay)
Invoke the closure after the delayed time
Definition: SHost.cs:102
SineSpace.Scripting.Scene.SHost.Stop
void Stop()
Pauses the current script until it is manually restarted, at the end of the current function/method; ...
Definition: SHost.cs:70
SineSpace.Scripting.Scene.SHost.InvokeEvent
void InvokeEvent(string name)
Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.
Definition: SHost.cs:32