(Created page with " =Members= {{ScriptFunction|void|SetGlobal|(string namespace, string key, DynValue value);|Sets a global key to a value. The value can be any object type.|5= '''Space.Shared.S...") |
|||
Line 2: | Line 2: | ||
=Members= | =Members= | ||
{{ScriptFunction|void|SetGlobal|(string namespace, string key, DynValue value);|Sets a global key to a value. The value can be any object type.|5= | {{ScriptFunction|void|SetGlobal|(string namespace, string key, DynValue value);|Sets a global key to a value. The value can be any object type.|5= | ||
− | '''Space.Shared.SetGlobal'''("com.someNameHere.world", "version", "1.02"); |6= | + | '''Space.Shared.SetGlobal'''("com.someNameHere.world", "version", "1.02"); |6=}} |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
{{ScriptFunction|DynValue|GetGlobal|(string namespace, string key);|Retrieves a previously set global variable, or returns nil.|5= | {{ScriptFunction|DynValue|GetGlobal|(string namespace, string key);|Retrieves a previously set global variable, or returns nil.|5= | ||
− | local versionValue = '''Space.Shared.GetGlobal'''("com.someNameHere.world", "version")|6= | + | local versionValue = '''Space.Shared.GetGlobal'''("com.someNameHere.world", "version")|6=}} |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
{{ScriptFunction|void|RegisterFunction|(string ns, string func, Closure reference);|Makes func into a global function that can be accessed anywhere.|5= | {{ScriptFunction|void|RegisterFunction|(string ns, string func, Closure reference);|Makes func into a global function that can be accessed anywhere.|5= | ||
Line 91: | Line 39: | ||
{{ScriptFunction|void|CallFunction|(string ns, string func, IEnumerable< DynValue > args);|Calls the registered function with the specified arguments.|5= | {{ScriptFunction|void|CallFunction|(string ns, string func, IEnumerable< DynValue > args);|Calls the registered function with the specified arguments.|5= | ||
− | '''Space.Shared.CallFunction'''("com.someNameHere.world", "func",{"Smith"}); |6= | + | '''Space.Shared.CallFunction'''("com.someNameHere.world", "func",{"Smith"}); |6=}} |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
{{ScriptFunction|void|RegisterBroadcastFunction|(string ns, string func, Closure reference);|Makes func into a global function that can be accessed anywhere.|5= | {{ScriptFunction|void|RegisterBroadcastFunction|(string ns, string func, Closure reference);|Makes func into a global function that can be accessed anywhere.|5= |
Sets a global key to a value. The value can be any object type.
Retrieves a previously set global variable, or returns nil.
Makes func into a global function that can be accessed anywhere.
Space.Log("Hello " .. name);
end
--Script placed on object A will allow other objects to call one of it's registered functions when clicked --Script in Object A thisObject = Space.Host.ExecutingObject namespace = "com.example.shared" LogFunction = function(Parameter) Space.Log("I've been called with parameter: " .. Parameter) end Space.Shared.RegisterFunction(namespace, "Log", LogFunction) -- Script in Other Objects thisObject = Space.Host.ExecutingObject namespace = "com.example.shared" OnClick = function() Space.Shared.CallFunction(namespace, "Log", {"Example"}) end thisObject.AddClickable() thisObject.Clickable.OnClick(OnClick)
Calls the registered function with the specified arguments.
Makes func into a global function that can be accessed anywhere.
Space.Log("Hello " .. name);
end
Calls every registered broadcast function with the specified arguments, and returns the number of calls queued.
function someFunction(status)
if status == "start"
then Space.Log("Do receiver 1 procedures.")
end
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
-- Script B: Another Receiver
function someFunction(status)
if status == "start"
then Space.Log("Do receiver 2 procedures.")
end
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
--Script C: Sender
local ball = Space.Host.ExecutingObject;
ball.SubscribeToEvents();
function onDown()
local queue = Space.Shared.CallBroadcastFunction("com.someNameHere.world", "func", {"start"});
Space.Log("number in queue: " .. queue);
end
Unregister Broadcast Function.
function someFunction(status)
if status == "start"
then Space.Log("Do receiver 1 procedures.")
end
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
-- Script B: Another Receiver
function someFunction(status)
if status == "start"
then Space.Log("Do receiver 2 procedures.")
end
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
--Script C: Sender
local ball = Space.Host.ExecutingObject;
ball.SubscribeToEvents();
function onDown()
local queue = Space.Shared.CallBroadcastFunction("com.someNameHere.world", "func", {"start"});
Space.Log("number in queue: " .. queue);
Space.Shared.UnregisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
Space.Log("UnregisterBroadcastFunction");
end
Unregister Broadcast Function.
function someFunction(status)
if status == "start"
then Space.Log("Do receiver 1 procedures.")
end
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
-- Script B: Another Receiver
function someFunction(status)
if status == "start"
then Space.Log("Do receiver 2 procedures.")
end
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
--Script C: Sender
local ball = Space.Host.ExecutingObject;
ball.SubscribeToEvents();
function onDown()
local queue = Space.Shared.CallBroadcastFunction("com.someNameHere.world", "func", {"start"});
Space.Log("number in queue: " .. queue);
Space.Shared.UnregisterBroadcastFunction("com.someNameHere.world", "func");
Space.Log("UnregisterBroadcastFunction");
end
Sets a Super global key to a value. The value can be any object type.
--these two scripts are in two different regions but script B will know that you came from A --REGION A script username = Space.Scene.PlayerAvatar.Username region = Space.Scene.Name Space.Shared.SetSuperGlobal (username, "Last Location", region) --REGION B script username = Space.Scene.PlayerAvatar.Username region = Space.Shared.GetSuperGlobal (username, "Last Location") Space.Dialogues.SendLocalChat ("You have arrived from ".. region, "Last Location")
Retrieves a previously set super global variable, or returns nil.
--these two scripts are in two different regions but script B will know that you came from A --REGION A script username = Space.Scene.PlayerAvatar.Username region = Space.Scene.Name Space.Shared.SetSuperGlobal (username, "Last Location", region) --REGION B script username = Space.Scene.PlayerAvatar.Username region = Space.Shared.GetSuperGlobal (username, "Last Location") Space.Dialogues.SendLocalChat ("You have arrived from ".. region, "Last Location")
|