wiki.sine.space | sinespace

Difference between revisions of "Scripting/SScriptingRuntime"

From wiki.sine.space
Jump to: navigation, search
(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...")
 
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/sscriptingruntime")
 
Line 1: Line 1:
=Members=
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/sscriptingruntime
 
+
{{ScriptFunction|SResource|GetResource|(string name)| Get the resource by its name and return it.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
local getRes=scripts.GetResource("Cube (2)")<br>
+
Space.Log(getRes.Name)<br>
+
''--if "Cube (2)" exits, return its name.''
+
}}
+
 
+
{{ScriptFunction|void|CallScriptFunction|(string name, params DynValue[] arguments)|Call registered script function with specified arguments.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
scripts.CallScriptFunction("Fun","Hello Lua!")<br>
+
function Fun(a)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(a)<br>
+
end<br>
+
''--prints "Hello Lua!".''
+
}}
+
 
+
{{ScriptFunction|void|CallScriptFunction|(string name)|Call registered script function.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
scripts.CallScriptFunction("Fun")<br>
+
function Fun()<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;local a="Hello Lua!"<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(a)<br>
+
end<br>
+
''--prints "Hello Lua!".''
+
}}
+
 
+
{{ScriptFunction|void|Reset|()|Reset event members to their initial values.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
scripts.CallScriptFunction("Fun")<br>
+
function Reset()<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;scripts.Reset()<br>
+
end<br>
+
function Fun()<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;local a="Hello Lua!"<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(a)<br>
+
end
+
}}
+
 
+
{{ScriptFunction|object|GetPublicVariable|(string name)|Gets the public variable by its name and return it.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
local publicVariabl = scripts.GetPublicVariable("no1")<br>
+
Space.Log(publicVariabl)
+
}}
+
 
+
{{ScriptFunction|void|SetPublicVariable|(string name, DynValue property);|Set the property to public variable with name "name".|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
scripts.SetPublicVariable("no1","var1",false)<br>
+
local publicVariabl = scripts.GetPublicVariable("no1")<br>
+
Space.Log(publicVariabl)<br>
+
''--set "var1" as "no1" corresponding value.''
+
}}
+
 
+
{{ScriptFunction|void|InvokeEvent|(string name)|Invokes the event with the name "name".|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
scripts.InvokeEvent("event1")<br>
+
function Fun()<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;a="Hello Lua!"<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(a)<br>
+
end<br>
+
''--prints "Hello Lua!".''
+
}}
+
 
+
 
+
 
+
=Properties=
+
 
+
{{ScriptFunction|SResource|Resources|{get;}|Return a list of resource.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
local resources=scripts.Resources<br>
+
for i = 0, #resources-1 do<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(resources[i].Name)<br>
+
end<br>
+
''--print resource name.''
+
}}
+
 
+
 
+
{{ScriptFunction|bool|Enabled|{get;set;}|Whether the scripting runtime component is Enabled.|5=
+
local thisObject=Space.Host.ExecutingObject<br>
+
local scripts=thisObject.Script<br>
+
Space.Log(scripts.Enabled)<br>
+
''--print true.''
+
}}
+
 
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 06:23, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/sscriptingruntime