Finds a single Game Object matching 'Name' and returns it. Can use '/' characters to designate a path (e.g. 'Parent/Child' returns Child with 'Parent')
Parameter
Type
Description
Space.Scene.Find('Door2')
hand = Space.Scene.Find("Hand");--This returns the GameObject named Hand.hand = Space.Scene.Find("/Hand");--This returns the GameObject named Hand.--Hand must not have a parent in the Hierarchy view.hand = Space.Scene.Find("/Monster/Arm/Hand");--This returns the GameObject named Hand,--which is a child of Arm > Monster.--Monster must not have a parent in the Hierarchy view.hand = Space.Scene.Find("Monster/Arm/Hand");--This returns the GameObject named Hand,--which is a child of Arm > Monster.
Finds a single Game Object using ID and returns it
Parameter
Type
Description
--add Scene Object Database to a Gameobject, set "123" to IDs and name the GameObject "Cube".local obj=Space.Scene.FindID("123")Space.Log(obj.Name);--print "Cube" if the object exists.
Marks the Game Object as temporary. Temporary objects will be cleaned up automatically if the script is destroyed or reset. Can be used to handle cleanup from procedural objects created by a script.
--clicking this object will create a GameObject from a resource and place it above our avatarthisObject = Space.Host.ExecutingObjectthisPlayer = Space.Scene.PlayerAvatarresource = Space.GetResource("Tomato") --add it as resource in your Scripting Runtime componentOnClick=function()createdObject = Space.Scene.CreateGameObject(resource) createdObject.WorldPosition = thisPlayer.GameObject.WorldPosition + thisPlayer.GameObject.UpendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
SwitchToInstance
void SwitchToInstance (uint id)
Switch to a shard region.
Parameter
Type
Description
Space.Scene.SwitchToInstance(2)
OnPlayerJoin
void OnPlayerJoin (Closure e)
Event which fires whenever a player joins the region
Parameter
Type
Description
e
Closure (Callback)
e(SAvatar)
--Place this script in a UIText object and it will--update itself with the name of the last player joinedfunctionupdateText(Av) --we include "Av" here because the event gives us a reference to the Avatar that joinedSpace.Host.ExecutingObject.UIText.Text="Last player joined: " .. Av.UsernameendSpace.Scene.OnPlayerJoin(updateText) -- updateText will now be called everytime a player joins
OnPlayerLeave
void OnPlayerLeave (Closure e)
Event which fires whenever a player leaves the region
--Place this script in a UIText object and it will--update itself with the name of the last player leftfunctionupdateText(Av) --we include "Av" here because the event gives us a reference to the Avatar that has leftSpace.Host.ExecutingObject.UIText.Text="Last player left: " .. Av.UsernameendSpace.Scene.OnPlayerLeave(updateText) -- updateText will now be called every time a player leaves
OnEditModeStart
void OnEditModeStart (Closure e)
An event which is fired when player enters Room Edit mode
Parameter
Type
Description
Space.Scene.OnEditModeStart(AFunctionName)
--makes an object become active upon entering edit modethisObject = Space.Host.ExecutingObjecttargetObject = Space.Host.GetReference("target") --add to references in Scripting Runtime componentfunctionOnEditModeFunction() targetObject.Active =trueendSpace.Scene.OnEditModeStart(OnEditModeFunction)
OnEditModeEnd
void OnEditModeEnd (Closure e)
An event which is fired when player exits Room Edit mode
Parameter
Type
Description
Space.Scene.OnEditModeEnd(AfunctionName)
--makes an object become active upon exiting edit modethisObject = Space.Host.ExecutingObjecttargetObject = Space.Host.GetReference("target") --add to references in Scripting Runtime componentfunctionOnEditModeFunction() targetObject.Active =falseendSpace.Scene.OnEditModeEnd(OnEditModeFunction)
OnEditModeAdd
void OnEditModeAdd (Closure e)
An event which is fired when object is added during Edit Mode
Parameter
Type
Description
Space.Scene.OnEditModeAdd(AFunctionName)
--prints the total number of objects in the scene whenever a new object is added in edit modefunctionOnEditModeFunction() Space.Log(#Space.Scene.Objects)end Space.Scene.OnEditModeAdd(OnEditModeFunction)
OnEditModeRemove
void OnEditModeRemove (Closure e)
An event which is fired when object is deleted during Edit Mode
Parameter
Type
Description
Space.Scene.OnEditModeRemove(AFunctionName)
--prints the total number of objects in the scene whenever a new object is removed in edit modefunctionOnEditModeFunction() Space.Log(#Space.Scene.Objects)end Space.Scene.OnEditModeRemove(OnEditModeFunction)
Returns the current player avatar. If this script is calling this upon initialisation, the Player may not exist yet, and you will want to wait a few frames until the avatar is present before continuing.
--this script, once clicked, will get all avatars in the scene--and print their ID, Username and Title (excluding self)--(Example: scoreboards/radars/scanners/game machines)thisGameObject = Space.Host.ExecutingObjectOnClick=function()Avatars = Space.Scene.Avatarsif#Avatars >0thenfor var=1, #Avatars dolocal ID = Avatars[var].IDlocal Username = Avatars[var].Usernamelocal Title = Avatars[var].Titleif Title =="" then Title ="None" end Space.Log("ID: " .. ID ..", Username: " .. Username ..", Title: " .. Title)endelse Space.Log("No Avatars")endendthisGameObject.AddClickable() thisGameObject.Clickable.Tooltip ="Click to print all avatars' information"thisGameObject.Clickable.OnClick(OnClick)
Returns a list of all avatars in the scene. The player avatar that is calling this will be added to the end of the list.
local avatars=Space.Scene.AllAvatarsSpace.Log(#avatars)--Print the length of AllAvatars.
--this script, once clicked, will get all avatars in the scene--and print their ID, Username and Title (including self)--(Example: scoreboards/radars/scanners/game machines)thisGameObject = Space.Host.ExecutingObjectOnClick=function()allAvatars = Space.Scene.AllAvatarsfor var=1, #allAvatars dolocal ID = allAvatars[var].IDlocal Username = allAvatars[var].Usernamelocal Title = allAvatars[var].Titleif Title =="" then Title ="None" end Space.Log("ID: " .. ID ..", Username: " .. Username ..", Title: " .. Title)endendthisGameObject.AddClickable() thisGameObject.Clickable.Tooltip ="Click to print all avatars' information"thisGameObject.Clickable.OnClick(OnClick)
Returns a list of Objects in the scene. IMPORTANT: This function is slow, you should cache the result and avoid calling this every frame.
objects = Space.Scene.Objects
--clicking this object will print a name of every object in the scene--[better use a coroutine incase the foor loop exceeds allowed frame time] thisObject = Space.Host.ExecutingObjectOnClickFunction=function()local objects = Space.Scene.Objectsfor i=1, #objects, 1do Space.Log(objects[i].Name)endend thisObject.AddClickable()
Name
string Nameget
Returns the name of the current region
RegionName = Space.Scene.Name
--this object will be clickable only if it is in a region called "X Region"--((for example: limiting object functionality to a specific region))thisObject = Space.Host.ExecutingObjectOnClick=function()Space.Log("We are in X Region")endif Space.Scene.Name =="X Region" thenthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)end
Url
string Urlget
Returns the URL of the current region
RegionUrl = Space.Scene.Url
--the URL of this region will be placed in a UIText upon loading --and also printed if this object is clickedthisObject = Space.Host.ExecutingObjecttextObject = Space.Host.GetReference("textObject") -- add to scripting runtime referencesfunctionOnClick() Space.Log(Space.Scene.Url)endtextObject.UIText.Text = Space.Scene.UrlthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
RegionID
long RegionIDget
Returns the region ID of current region.
Space.Log(Space.Scene.RegionID)
--the RegionID of this region will be placed in a UIText upon loading --and also printed if this object is clickedthisObject = Space.Host.ExecutingObjecttextObject = Space.Host.GetReference("textObject") -- add to scripting runtime referencesfunctionOnClick() Space.Log(Space.Scene.RegionID)endtextObject.UIText.Text = Space.Scene.RegionIDthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
InstanceID
long InstanceIDget
Return the instance ID of current region.
instanceID = Space.Scene.InstanceID
--the RegionID of this region will be placed in a UIText upon loading --and also printed if this object is clickedthisObject = Space.Host.ExecutingObjecttextObject = Space.Host.GetReference("textObject") -- add to scripting runtime referencesfunctionOnClick() Space.Log(Space.Scene.InstanceID)endtextObject.UIText.Text = Space.Scene.InstanceIDthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
Owner
long Ownerget
Returns the avatar ID of the regions owner
RegionOwner = Space.Scene.Owner
--this script will make this object only clickable for the region ownerthisObject = Space.Host.ExecutingObjectthisPlayer = Space.Scene.PlayerAvatarOnClick=function()Space.Log("Do Something")endif thisPlayer.ID == Space.Scene.Owner thenthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)end
PlayerIsOwner
bool PlayerIsOwnerget
Returns whether the current player is the owner of the region
isOwner = Space.Scene.PlayerIsOwner
--this script will make the object a clickable, but only if player is region owner--(Example: Access control)thisGameObject = Space.Host.ExecutingObjectOnClick=function()Space.Log("this click was only possible because you are a region Owner")endif Space.Scene.PlayerIsOwner thenthisGameObject.AddClickable()thisGameObject.Clickable.Tooltip ="Click me"thisGameObject.Clickable.OnClick(OnClick) end
PlayerIsAdmin
bool PlayerIsAdminget
Does this Player have the Admin role?
Space.Scene.PlayerIsAdmin
--this script will make the object a clickable, but only if player is region Admin--(Example: Access control)thisGameObject = Space.Host.ExecutingObjectOnClick=function()Space.Log("this click was only possible because you are a region Admin")endif Space.Scene.PlayerIsAdmin thenthisGameObject.AddClickable()thisGameObject.Clickable.Tooltip ="Click me Admin"thisGameObject.Clickable.OnClick(OnClick) end
PlayerIsModerator
bool PlayerIsModeratorget
Does this Player have the Moderator role?
playerIsModerator = Space.Scene.PlayerIsModerator
--this script will make the object a clickable, but only if player is Moderator in this region--(Example: Access control)thisGameObject = Space.Host.ExecutingObjectOnClick=function()Space.Log('this click was only possible because you are Moderator in this region')endif Space.Scene.PlayerIsModerator thenthisGameObject.AddClickable()thisGameObject.Clickable.Tooltip ="Click me Moderator"thisGameObject.Clickable.OnClick(OnClick) end
PlayerIsDeveloper
bool PlayerIsDeveloperget
Does this Player have the Developer role?
playerIsDeveloper = Space.Scene.PlayerIsDeveloper
PlayerIsTrusted
bool PlayerIsTrustedget
Does this Player have the Trusted role?
playerIsTrusted = Space.Scene.PlayerIsTrusted
--this script will make the object a clickable, but only if player is Trusted in this region--(Example: Access control)thisGameObject = Space.Host.ExecutingObjectOnClick=function()Space.Log("this click was only possible because you are Trusted in this region")endif Space.Scene.PlayerIsTrusted thenthisGameObject.AddClickable()thisGameObject.Clickable.Tooltip ="Click me Trusted"thisGameObject.Clickable.OnClick(OnClick) end
IsInEditMode
bool IsInEditModeget
Returns true if current player is in edit mode.
Space.Log(Space.Scene.IsInEditMode)
--makes an object only active when this player is in Edit ModethisObject = Space.Host.ExecutingObjecttargetObject = Space.Host.GetReference("target") --add to references in Scripting Runtime componentfunctionOnUpdateFunction() targetObject.Active = Space.Scene.IsInEditMode endthisObject.OnUpdate(OnUpdateFunction)