Line 8: | Line 8: | ||
''--Attach the upon function to Scripting Runtime/Unity Interfaces/Events,Named "InvokeExample.''<br><br> | ''--Attach the upon function to Scripting Runtime/Unity Interfaces/Events,Named "InvokeExample.''<br><br> | ||
Space.Host.InvokeEvent("InvokeExample");<br> | Space.Host.InvokeEvent("InvokeExample");<br> | ||
− | ''-- | + | ''--Print "Invoke Event" to the console.'' |
}} | }} | ||
Line 28: | Line 28: | ||
local obj=Space.Host.ExecutingObject;<br> | local obj=Space.Host.ExecutingObject;<br> | ||
Space.Log(obj.Name);<br> | Space.Log(obj.Name);<br> | ||
− | ''-- | + | ''--Print object name to the console.'' |
}} | }} | ||
{{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'| | ||
Space.Log(Space.Host.Language);<br> | Space.Log(Space.Host.Language);<br> | ||
− | ''-- | + | ''--Print current system language in English.'' |
}} | }} | ||
Line 60: | Line 60: | ||
Space.Log("InvokeDelayed")<br> | Space.Log("InvokeDelayed")<br> | ||
end,5)<br> | end,5)<br> | ||
− | ''-- | + | ''--Print "InvokeDelayed" after 5 seconds.'' |
}} | }} | ||
{{ScriptFunction|bool|ReferenceExists|(string name)|Return true when the reference object exists and is not empty.| | {{ScriptFunction|bool|ReferenceExists|(string name)|Return true when the reference object exists and is not empty.| | ||
Space.Log(Space.Host.ReferenceExists("obj"));<br> | Space.Log(Space.Host.ReferenceExists("obj"));<br> | ||
− | ''-- | + | ''--Print "false" to console if didn't set the object named "obj" to the Object Reference.'' |
}} | }} | ||
{{ScriptFunction|bool|ReferenceExistsAndNotEmpty|(string name)|Return true when the reference object exists and is not empty.| | {{ScriptFunction|bool|ReferenceExistsAndNotEmpty|(string name)|Return true when the reference object exists and is not empty.| | ||
Space.Log(Space.Host.ReferenceExistsAndNotEmpty("obj"));<br> | Space.Log(Space.Host.ReferenceExistsAndNotEmpty("obj"));<br> | ||
− | ''-- | + | ''--Print "false" to console if didn't set the object named "obj" to the Object References or attach the reference to "obj".'' |
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SGameObject|GetReference|(string name)|Return SGameObject which attaches to the reference.|5= | ||
+ | local obj=Space.Host.GetReference("obj");<br> | ||
+ | Space.Log(obj==nil);<br> | ||
+ | ''--Print "true" if didn't set the object named "obj" to the Object References or attach the reference to "obj".'' | ||
}} | }} | ||
{{Scripting Navbox}} | {{Scripting Navbox}} |
The SHost class represents the scripting runtime.
Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.
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.
Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well.
trans.SubscribeToEvents();
function Running()
Space.Log("Running")
end
trans.OnUpdate(Running)
Space.Host.InvokeDelayed(function()
Space.Log("Stop")
Space.Host.Stop()
end,5)
Returns the SGameObject this script is attached to.
Space.Log(obj.Name);
Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'
Space.Log(Space.Host.Language);
--Print current system language in English.
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 be 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);
Invoke the closure after the delayed time.
Space.Host.InvokeDelayed(function()
Space.Log("InvokeDelayed")
end,5)
--Print "InvokeDelayed" after 5 seconds.
Return true when the reference object exists and is not empty.
Space.Log(Space.Host.ReferenceExists("obj"));
--Print "false" to console if didn't set the object named "obj" to the Object Reference.
Return true when the reference object exists and is not empty.
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".
Return SGameObject which attaches to the reference.
Space.Log(obj==nil);
|