Sinespace Client  2023.2.17543
Client-side scripting for Sinespace
SineSpace.Scripting.Components.SScriptingRuntime Class Reference
Inheritance diagram for SineSpace.Scripting.Components.SScriptingRuntime:
ScriptClassComponent< ScriptingRuntimeBaseInternal >

Public Member Functions

SResource GetResource (string name)
 Get the resource by its name and return it. More...
 
void CallScriptFunction (string name, params DynValue[] arguments)
 Calls registered script function with specified arguments Function will be called at the start of their next execution context, which may be in the next frame. More...
 
void CallScriptFunction (string name)
 
void Reset ()
 Resets the event members to their initial values. More...
 
object GetPublicVariable (string name)
 Gets the public variable by its name and return it. More...
 
void SetPublicVariable (string name, DynValue property, bool persistent=false)
 Set the property to public variable with name "name" and whether to change persistent More...
 
void InvokeEvent (string name)
 Invokes the event with the name "name" More...
 

Properties

string ComponentName [get]
 Return the component name of the scripting runtime More...
 
SResource[] Resources [get]
 Return a list of resource More...
 
bool Enabled [get, set]
 Whether the scriptingRuntime component is enabled or not More...
 
- Properties inherited from ScriptClassComponent< ScriptingRuntimeBaseInternal >
SGameObject GameObject [get]
 Return the GameObject which component added. More...
 

Member Function Documentation

◆ CallScriptFunction() [1/2]

void SineSpace.Scripting.Components.SScriptingRuntime.CallScriptFunction ( string  name)

◆ CallScriptFunction() [2/2]

void SineSpace.Scripting.Components.SScriptingRuntime.CallScriptFunction ( string  name,
params DynValue[]  arguments 
)

Calls registered script function with specified arguments Function will be called at the start of their next execution context, which may be in the next frame.

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
scripts.CallScriptFunction("Fun","Hello Lua!")
function Fun(a)
Space.Log(a)
&ndash;prints "Hello Lua!"
end
Parameters
nameThe name of function
argumentsThe parameters of the function need

summary> Call registered script function Function will be called at the start of their next execution context, which may be in the next frame. /summary>

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
scripts.CallScriptFunction("Fun")
function Fun()
local a="Hello Lua!"
Space.Log(a)
&ndash;prints "Hello Lua!"
end

param name="name">The name of function

◆ GetPublicVariable()

object SineSpace.Scripting.Components.SScriptingRuntime.GetPublicVariable ( string  name)

Gets the public variable by its name and return it.

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
local publicVariabl = scripts.GetPublicVariable("no1")
Space.Log(publicVariabl)
Parameters
nameThe name of public variable

◆ GetResource()

SResource SineSpace.Scripting.Components.SScriptingRuntime.GetResource ( string  name)

Get the resource by its name and return it.

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
local getRes=scripts.GetResource("Cube (2)")
Space.Log(getRes.Name)
&ndash;if "Cube (2)" exits, return its name.
Parameters
nameThe name of resource

◆ InvokeEvent()

void SineSpace.Scripting.Components.SScriptingRuntime.InvokeEvent ( string  name)

Invokes the event with the name "name"

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
scripts.InvokeEvent("event1")
function Fun()
a="Hello Lua!"
Space.Log(a)
<br>
end
&ndash;prints "Hello Lua!"
Parameters
nameThe name of event

◆ Reset()

void SineSpace.Scripting.Components.SScriptingRuntime.Reset ( )

Resets the event members to their initial values.

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
scripts.CallScriptFunction("Fun")
function Reset()
scripts.Reset()
end
function Fun()
local a="Hello Lua!"
Space.Log(a)
end

◆ SetPublicVariable()

void SineSpace.Scripting.Components.SScriptingRuntime.SetPublicVariable ( string  name,
DynValue  property,
bool  persistent = false 
)

Set the property to public variable with name "name" and whether to change persistent

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
scripts.SetPublicVariable("no1","var1",false)
local publicVariabl = scripts.GetPublicVariable("no1")
Space.Log(publicVariabl)
&ndash;set "var1" as "no1" corresponding value
Parameters
nameThe name of public variable
propertyRepresent a value in a Lua/MoonSharp script.
persistentwhether to change persistent

Property Documentation

◆ ComponentName

string SineSpace.Scripting.Components.SScriptingRuntime.ComponentName
get

Return the component name of the scripting runtime

local thisObject=Space.Host.ExecutingObject
local script=thisObject.Script
Space.Log(script.ComponentName)

◆ Enabled

bool SineSpace.Scripting.Components.SScriptingRuntime.Enabled
getset

Whether the scriptingRuntime component is enabled or not

local thisObject=Space.Host.ExecutingObject
<br>
local scripts=thisObject.Script
Space.Log(scripts.Enabled)

◆ Resources

SResource [] SineSpace.Scripting.Components.SScriptingRuntime.Resources
get

Return a list of resource

local thisObject=Space.Host.ExecutingObject
local scripts=thisObject.Script
local resources=scripts.Resources
for i = 0, #resources-1 do
Space.Log(resources[i].Name)
end
SineSpace.Scripting.Components.SScriptingRuntime.Reset
void Reset()
Resets the event members to their initial values.
Definition: SScriptingRuntime.cs:126