wiki.sine.space | sinespace

Scripting/SScriptingRuntime

From wiki.sine.space
Revision as of 09:42, 28 December 2020 by Edisonwu (Talk | contribs) (Created page with "=Members= {{ScriptFunction|SResource|GetResource|(string name)| Get the resource by its name and return it.|5= local thisObject=Space.Host.ExecutingObject<br> local scripts=t...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Members

GetResource

SResource 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)

--if "Cube (2)" exits, return its name.


CallScriptFunction

void CallScriptFunction (string name, params DynValue[] arguments)

Call registered script function with specified arguments.

local thisObject=Space.Host.ExecutingObject

scripts.CallScriptFunction("Fun","Hello Lua!")
function Fun(a)
    Space.Log(a)
end

--prints "Hello Lua!".


CallScriptFunction

void CallScriptFunction (string name)

Call registered script function.

local thisObject=Space.Host.ExecutingObject

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

--prints "Hello Lua!".


Reset

void Reset ()

Reset 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


GetPublicVariable

object 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)


SetPublicVariable

void SetPublicVariable (string name, DynValue property);

Set the property to public variable with name "name".

local thisObject=Space.Host.ExecutingObject

local scripts=thisObject.Script
scripts.SetPublicVariable("no1","var1",false)
local publicVariabl = scripts.GetPublicVariable("no1")
Space.Log(publicVariabl)

--set "var1" as "no1" corresponding value.


InvokeEvent

void 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)
end

--prints "Hello Lua!".



Properties

Resources

SResource 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

--print resource name.



Enabled

bool Enabled {get;set;}

Whether the scripting runtime component is Enabled.

local thisObject=Space.Host.ExecutingObject

local scripts=thisObject.Script
Space.Log(scripts.Enabled)

--print true.