-- This one script placed on a multiple number of objects will track the number-- of clicks user has made using a Global Variable-- note: the GetGlobal/SetGlobal functions are client sidethisObject = Space.Host.ExecutingObjectnamespace ="com.example.shared" key ="clicktracker"OnClick=function()local currentClicks = Space.Shared.GetGlobal(namespace, key)if currentClicks ==nilthen currentClicks =1else currentClicks = currentClicks +1endSpace.Shared.SetGlobal(namespace, key, currentClicks)Space.Log("Total Clicks = " .. currentClicks)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
-- This one script placed on a multiple number of objects will track the number-- of clicks user has made using a Global Variable-- note: the GetGlobal/SetGlobal functions are client sidethisObject = Space.Host.ExecutingObjectnamespace ="com.example.shared" key ="clicktracker"OnClick=function()local currentClicks = Space.Shared.GetGlobal(namespace, key)if currentClicks ==nilthen currentClicks =1else currentClicks = currentClicks +1endSpace.Shared.SetGlobal(namespace, key, currentClicks)Space.Log("Total Clicks = " .. currentClicks)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
GetSuperGlobal
DynValue GetSuperGlobal(string ns, string key)
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 scriptusername = Space.Scene.PlayerAvatar.Usernameregion = Space.Scene.NameSpace.Shared.SetSuperGlobal (username, "Last Location", region)--REGION B scriptusername = Space.Scene.PlayerAvatar.Usernameregion = Space.Shared.GetSuperGlobal (username, "Last Location")Space.Dialogues.SendLocalChat ("You have arrived from ".. region, "Last Location")
--Script placed on object A will allow other objects to call one of it's registered functions when clicked--Script in Object AthisObject = Space.Host.ExecutingObjectnamespace ="com.example.shared" LogFunction=function(Parameter)Space.Log("I've been called with parameter: " .. Parameter) endSpace.Shared.RegisterFunction(namespace, "Log", LogFunction)-- Script in Other ObjectsthisObject = Space.Host.ExecutingObjectnamespace ="com.example.shared" OnClick=function()Space.Shared.CallFunction(namespace, "Log", {"Example"}) endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
--Script placed on object A will allow other objects to call one of it's registered functions when clicked--Script in Object AthisObject = Space.Host.ExecutingObjectnamespace ="com.example.shared" LogFunction=function(Parameter)Space.Log("I've been called with parameter: " .. Parameter) endSpace.Shared.RegisterFunction(namespace, "Log", LogFunction)-- Script in Other ObjectsthisObject = Space.Host.ExecutingObjectnamespace ="com.example.shared" OnClick=function()Space.Shared.CallFunction(namespace, "Log", {"Example"}) endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)