Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
[] RayCast ( origin, normal, float distance, layerMask=null)
Raycasts from origin along normal, distance meters - and returns a list of collisions in distance order (closest first)
RayCastSingle ( origin, normal, float distance, layerMask=null)
Raycasts from origin along normal, distance meters - and returns the first collision.
[] SphereCast ( origin, float radius, float distance, direction, layerMask=null) [] SphereCast ( origin, float radius, float distance, layerMask=null)
Sweeps from origin in a spherical ray 'radius' wide, and returns the list of collided objects
[] CapsuleCast ( origin, end, float radius, float distance, up, SLayerMask layerMask=null) [] CapsuleCast ( origin, end, float radius, float distance, layerMask=null)
Sweeps a capsule from origin to end, radius wide and returns a list of collisions.
[] BoxCast ( origin, extents, direction, orientation, float distance, layerMask=null)
Sweeps a box defined by origin+halfExtents along direction, distance meters with a orientation matching orientation - and returns a list of collisions in distance order.
Gravity get set
The gravity applied to all rigid bodies in the Scene.
Gravity can be turned off for an individual Rigidbody using its property.
SLayerMask
Include a layer mask if you do not want to use viewer's defaults.
SPhysicsHit[] RayCast (SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
SPhysicsHit RayCastSingle (SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
SPhysicsHit[] SphereCast (SVector origin, float radius, float distance, SVector direction, SLayerMask layerMask=null) SPhysicsHit[] SphereCast (SVector origin, float radius, float distance, SLayerMask layerMask=null)
SPhysicsHit[] CapsuleCast (SVector origin, SVector end, float radius, float distance, SVector up, SLayerMask layerMask=null) SPhysicsHit[] CapsuleCast (SVector origin, SVector end, float radius, float distance, SLayerMask layerMask=null)
SPhysicsHit[] BoxCast (SVector origin, SVector extents, SVector direction, SQuaternion orientation, float distance, SLayerMask layerMask=null)
SVector Gravity get set
origin
SVector
normal
SVector
distance
SVector
layerMask
tableSPhysicsHit = Space.Physics.RayCast(Vector.New(0,0,0), Vector.New(1,0,0), 2.0)local trans=Space.Host.ExecutingObject
function Raycast()
local rays = Space.Physics.RayCast(trans.WorldPosition,trans.Forward,50)
if(rays~=nil and #rays>0) then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(Raycast)SPhysicsHit = Space.Physics.RayCastSingle(Vector.New(0,0,0), Vector.New(1,0,0), 2.0)local trans=Space.Host.ExecutingObject
function RaycastSingle()
local ray=Space.Physics.RayCastSingle(trans.WorldPosition,trans.Forward,50)
if(ray~=nil and ray.ContainsHit==true) then
Space.Log(ray.Object.Name) end
end
trans.OnUpdate(RaycastSingle) --this script will make this object jump to wherever you right click
--(Example: moving objects with right click )
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate) tableSPhysicsHit = Space.Physics.SphereCast(Vector.New(0,0,0), 3.0, 2.0, Vector.New(1,0,0))
--or
tableSPhysicsHit = Space.Physics.SphereCast(Vector.New(0,0,0), 3.0, 2.0)local trans=Space.Host.ExecutingObject
function SphereRaycast()
local center=trans.WorldPosition + Vector.New(0.5,0.5,0.5)
local rays=Space.Physics.SphereCast(center,10,10,trans.Forward)
if rays~=nil and #rays>0 then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(SphereRaycast)tableSPhysicsHit = Space.Physics.CapsuleCast(Vector.New(0,0,0),Vector.New(0,5,0), 3.0, 2.0, Vector.New(1,0,0))
--or
tableSPhysicsHit = Space.Physics.CapsuleCast(Vector.New(0,0,0),Vector.New(0,5,0), 3.0, 2.0)local trans=Space.Host.ExecutingObject
function CapsuleCast()
local startp=trans.WorldPosition
local endp=startp+trans.Up*10
local rays=Space.Physics.CapsuleCast(startp,endp,1,10,trans.Up)
if rays~=nil and #rays>0 then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(CapsuleCast)tableSPhysicsHit = Space.Physics.BoxCast(Vector.New(0,0,0),Vector.New(1,1,1), Vector.New(0,1,0), Quaternion.New(0,60,0), 10.0)local trans=Space.Host.ExecutingObject
function BoxCast()
local center=trans.WorldPosition + Vector.New(0.5,0.5,0.5)
local endp=local extents=Vector.new(2,2,2)
local rays=Space.Physics.BoxCast(center,extents,trans.Forward,Quaternion.Identity,2)
if rays~=nil and #rays>0 then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(BoxCast)Space.Physics.Gravity = Vector.New(0,-1.0,0)void UpdateInfo (Closure onComplete)
Call the onComplete function upon the server saving a value.
string RetrieveValue (string key)
Returns the saved value with the key.
void SetValue (string key, string value)
Save a value to the storage record that is accessed with key.
void UpdateRegionInfo (Action onComplete) void UpdateRegionInfo (Closure onComplete)
Updates your local cache with the most up-to-date values from the server. This function should be called before using the function.
string RetrieveRegionValue (string key)
Retrieves the saved value from "key" from your local cache. The function should be called first to update your local cache with the most up-to-date values from the server.
void SetRegionValue (string key, string value)
Save the "value" to "key" on both your local cache and on the server.
void UpdateInfo (Closure onComplete)
string RetrieveValue (string key)
void SetValue (string key, string value)
void UpdateRegionInfo (Action onComplete) void UpdateRegionInfo (Closure onComplete)
string RetrieveRegionValue (string key)
void SetRegionValue (string key, string value)
key
string
Max length 48
value
string
Max length 255
key
string
Max length 48
value
string
Max length 255
function OnCompleteFunction()
--
end
Space.Persistence.UpdateInfo(OnCompleteFunction)Space.Persistence.SetValue("TestValue","123");
Space.Persistence.UpdateInfo(function ()
local value = Space.Persistence.RetrieveValue("TestValue")
Space.Log(value)
end)
--print "123" to console.Space.Persistence.RetrieveValue("TestValue")Space.Persistence.SetValue("MyValue", "Hello World");Space.Persistence.SetRegionValue("TestRegionValue","456")
Space.Persistence.UpdateRegionInfo(function ()
local value = Space.Persistence.RetrieveRegionValue("TestRegionValue")
Space.Log(value)
end)
--print "456" to console.Space.Persistence.RetrieveRegionValue("TestRegionValue");Space.Persistence.SetRegionValue("TestRegionValue","456");bool IsLocked get
Is the Camera locked?
MainCamera get
Note, this property is generally read-only. It's position is driven by internal code.
ActiveVirtualCamera get
The currently active Cinemachine Virtual Camera game object.
void LockCamera ()
Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until is called.
void ReleaseCamera ()
Calling this function reverses the call and returns control of the Camera to the viewer.
void SetCameraPositionOrientation ( position, orientation)
Sets the Camera's position and rotation. This function requires
ScreenCoordinatesToRay ( screenCoordinates)
Returns a ray going from camera through a screen point.
ScreenCoordinatesToWorld (screenCoordinates)
Transforms a point from screen space into world space.
WorldCoordinatesToScreen ( coordinates)
Function Description
void ShakeCamera (float magnitude, float time) void ShakeCamera (float amplitude, float frequency, float time)
Function Description
void LockCamera (SGameObject owner)
void ReleaseCamera ()
void SetCameraPositionOrientation (SVector position, SQuaternion orientation)
SRay ScreenCoordinatesToRay (SVector screenCoordinates)
SVector ScreenCoordinatesToWorld (SVector screenCoordinates)
SVector WorldCoordinatesToScreen (SVector coordinates)
void ShakeCamera (float magnitude, float time) void ShakeCamera (float amplitude, float frequency, float time)
bool IsLocked get
SGameObject MainCamera get
SGameObject ActiveVirtualCamera get
position
The World Postion of the camera GameObject.
orientation
The World Rotation of the camera GameObject.
isCameraLocked = Space.Camera.IsLockedmainCamera = Space.Camera.MainCameracurrentCamera = Space.Camera.ActiveVirtualCameraSpace.Camera.LockCamera()Space.Camera.ReleaseCamera()Space.Camera.SetCameraPositionOrientation (Vector.New(0,0,0),Quaternion.Euler(-60,0,0));cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,50,0)) --this script will make this object jump to wherever you right click
--(Example: moving objects with right click )
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate) obj = Space.Host.ExecutingObject;
Space.Log(Space.Camera.ScreenCoordinatesToWorld(Vector.New(0.5,0.5,0)).ToString());
-- Print 3 worldspace vectors created by screen space point to the console.local trans = Space.Host.ExecutingObject;
Space.Log(Space.Camera.WorldCoordinatesToScreen(trans.WorldPosition).ToString());
-- Print the position created by world space point to the console.Space.Camera.ShakeCamera(1, 1.0)
--or
Space.Camera.ShakeCamera(2, 1, 1.0)void (string name)
void ()
void (Closure c, float delay)
void (DynValue value, DynValue parameter=default(DynValue), string name=null) void (string value, DynValue parameter=default(DynValue)
bool (string name)
bool (string name)
SGameObject (string name)
void (string script)
SGameObject get
string get
void InvokeEvent (string name)
Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.
void Stop ()
Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well.
void InvokeDelayed (Closure c, float delay)
Invoke the closure after the delayed time.
void StartCoroutine (DynValue value, DynValue parameter=default(DynValue), string name=null) void StartCoroutine (string value, DynValue parameter=default(DynValue), string name=null)
Executes the specified function as a coroutine.
bool ReferenceExists (string name)
Return true when the reference object exists and is not empty.
bool ReferenceExistsAndNotEmpty (string name)
Return true when the reference object exists and is not empty.
SGameObject GetReference (string name)
Pulls a reference from the scripting runtime component's "References" section by it's name.
name
string
The name of the reference as set within the Scripting Runtime component (references section).
void Evaluate (string script)
Executes given Lua code/script. (white-label only)
SGameObject ExecutingObject get
A reference to the GameObject that is executing this script. (The GameObject that this Scripting Runtime component is attached to).
string Language get
Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'
Space.Host.InvokeEvent("EventName")Space.Host.Stop()local trans=Space.Host.ExecutingObject;
trans.SubscribeToEvents();
function Running()
Space.Log("Running")
end
trans.OnUpdate(Running)
Space.Host.InvokeDelayed(function()
Space.Log("Stop")
Space.Host.Stop()
end,5)
--After print the "Stop","Running" won't display anymore.Space.Host.InvokeDelayed(AFunction, 10)--Clicking this object makes it destroy itself after 5 seconds
thisObject = Space.Host.ExecutingObject
function DeleteFunction()
thisObject.Destroy()
end
function OnClickFunction()
Space.Host.InvokeDelayed(DeleteFunction,10)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)Space.Host.StartCoroutine(aFunction)
--or
Space.Host.StartCoroutine("aFunctionName")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);referenceExists = Space.Host.ReferenceExists("the reference name")existsNotEmpty = 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".theObject = Space.Host.GetReference("referenceName")--Clicking this object makes it destroy the object we linked in the references section
thisObject = Space.Host.ExecutingObject
dObject = Space.Host.GetReference("theObjectToBeDestroyed")
function OnClickFunction()
dObject.Destroy()
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)Space.Host.Evaluate('Space.Log("test")')object = Space.Host.ExecutingObjectlang = Space.Host.Language--Makes a UIText show a different message according to the client's language
TextObject = Space.Host.GetReference("TextObject") --add to references section of Scripting Runtime component
language = Space.Host.Language
if language == "English" then
TextObject.UIText.Text = "Welcome!"
elseif language == "Dutch" then
TextObject.UIText.Text = "welkom!"
elseif language == "French" then
TextObject.UIText.Text = "bienvenue!"
else
TextObject.UIText.Text = "Welcome!"
endCreateCommandBuffer ()
Return a new CommandBuffer.
void AddCommandBufferToCamera ( commandbuffer, int cameraEvent=19)
Add the CommandBuffer to the Main Camera.
void RemoveCommandBufferFromCamera ( commandbuffer, int cameraEvent=19)
Remove the CommandBuffer from the Main Camera.
void SetPostProfile ( customProfile)
Set a custom Space Post-Processing Profile.
void ClearPostProfile ()
Clear current Post-Processing profile and restore default one.
void SetCrepsecularRays (bool on, float thresR, float thresG, float thresB, float colorR, float colorG, float colorB, float falloff, float blurSize, int blurIterations, float intensity)
Function Description
void SetAmbientOcclusion (bool on, float intensity, bool aoOnly)
Function Description
void SetMotionBlur (bool on, float shutterAngle)
Function Description
void SetBloom (bool on, float threshold, float intensity)
Function Description
void SetAnamorphicFlares (bool on, float r, float g, float b, float intensity, float threshold, float spread, bool vertical)
Function Description
void SetVignette (bool on, float r, float g, float b, float intensity)
Function Description
void SetLensDirt (bool on, float threshold, SResource texture, float intensity)
Function Description
void SetChromaticAberrationPost (bool on, float strength, float cornerBlur)
Function Description
void SetFocus ( target)
Function Description
void SupressFocus ()
Function Description
void RestoreFocus ()
Function Description
void SetLookUpTable ( lut)
Function Description
void (bool on, float strength, float cornerBlur)
void (SGameObject target)
void ()
void ()
void (SResource lut)
SCommandBuffer CreateCommandBuffer ()
void AddCommandBufferToCamera (SCommandBuffer commandbuffer, int cameraEvent=19)
void RemoveCommandBufferFromCamera (SCommandBuffer commandbuffer, int cameraEvent=19)
void SetPostProfile (SResource customProfile)
void ClearPostProfile ()
void SetCrepsecularRays (bool on, float thresR, float thresG, float thresB, float colorR, float colorG, float colorB, float falloff, float blurSize, int blurIterations, float intensity)
void SetAmbientOcclusion (bool on, float intensity, bool aoOnly)
void SetMotionBlur (bool on, float shutterAngle)
void SetBloom (bool on, float threshold, float intensity)
void SetAnamorphicFlares (bool on, float r, float g, float b, float intensity, float threshold, float spread, bool vertical)
void SetVignette (bool on, float r, float g, float b, float intensity)
void (bool on, float threshold, SResource texture, float intensity)
commandBuffer = Space.PostFX.CreateCommandBuffer()local commandbuffer=Space.PostFX.CreateCommandBuffer()
local mat=Space.Resources[1]
local cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)Space.PostFX.AddCommandBufferToCamera(ACommandBuffer)
---or
Space.PostFX.AddCommandBufferToCamera(ACommandBuffer, 18)local commandbuffer=Space.PostFX.CreateCommandBuffer()
local mat=Space.Resources[1]
local cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)
function RemoveCommandBuffer()
--Bind this function to a button and then click it in playing.
Space.PostFX.RemoveCommandBufferFromCamera(commandbuffer)
endSpace.PostFX.RemoveCommandBufferToCamera(ACommandBuffer)
---or
Space.PostFX.RemoveCommandBufferToCamera(ACommandBuffer, 18)local commandbuffer=Space.PostFX.CreateCommandBuffer()
local mat=Space.Resources[1]
local cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)
function RemoveCommandBuffer()
--Bind this function to a button and then click it in playing.
Space.PostFX.RemoveCommandBufferFromCamera(commandbuffer)
endSpace.PostFX.SetPostProfile(Space.Resources[1])Space.PostFX.ClearPostProfile()Space.PostFX.SetCrepsecularRays(true, 255.0, 0.0, 0.0, 0.0,0.0, 255.0, 1.0, 1.0, 2, 4.0)Space.PostFX.SetAmbientOcclusion(true, 4.0, true)Space.PostFX.SetMotionBlur(true, 20.0)Space.PostFX.SetBloom(true, 2.0, 4.0)Space.PostFX.SetBloom(true, 255.0, 0.0, 0.0, 4.0, 2.0, 3.0, true)Space.PostFX.SetVignette(true, 255.0, 0.0, 0.0, 4.0)Space.PostFX.SetLensDirt(true, 4.0, Space.Resources[1], 4.0)Space.PostFX.SetChromaticAberrationPost(true, 4.0, 1.0)Space.PostFX.SetFocus(Space.Host.ExecutingObject)Space.PostFX.SupressFocus()Space.PostFX.RestoreFocus()Space.PostFX.SetLookUpTable(Space.Resources[1])void GetEnabledUserRegions (Closure onComplete)
Calling this function will asynchronously get and return information about this player's regions as (This is the same information in the "Region List" window).
void GetRegionTexture (region, Closure onComplete) void GetRegionTexture (string json, Closure onComplete)
Returns the Region Texture (the image seen while loading the region) as a resource. This function requires an object to identify which region. (white-label grids only)
void GetOutfits (Closure onComplete)
Calling this function will asynchronously get and return information about this player's outfits as a List of .
bool IsWhiteLabel get
Returns true if this Grid is a white-label Grid.
bool PlayerIsAdmin get
Returns true if this player's Grid role is Admin.(white-label grid only)
bool PlayerIsModerator get
Returns true if this player's Grid role is Moderator. (white-label grid only)
bool PlayerIsDeveloper get
Returns true if this player's Grid role is Developer.(white-label grid only)
bool PlayerIsTrusted get
Returns true if this player's Grid role is Trusted.(white-label grid only)
ThemeColor1 get
The viewer's Theme Color 1.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
ThemeColor2 get
The viewer's Theme Color 2.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
ThemeColor3 get
The viewer's Theme Color 3.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
ThemeColor4 get
The viewer's Theme Color 4.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
TextColor1 get
The viewer's Text Color 1.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
TextColor2 get
The viewer's Text Color 2.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
string Name get
Returns the Grid's Name. (white-label grid only)
string SiteURL get
Returns the Grid's Site URL. (white-label grid only)
int DefaultRegion get
Returns the Region ID of the Default Region. The Default Region is set in the grid's Dashboard. (white-label grid only)
int[] Avatars get
Returns the IDs of all Avatars in the grid. (white-label grid only)
int OrientationRegion get
Returns the Region ID of the "Orientation Region".
SColor get
string get
string get
int get
int[] get
int get
void GetEnabledUserRegions (Closure onComplete)
void GetRegionTexture (SPublicRegion region, Closure onComplete) void GetRegionTexture (string json, Closure onComplete)
void GetOutfits (Closure onComplete)
bool IsWhiteLabel get
bool PlayerIsAdmin get
bool PlayerIsModerator get
bool PlayerIsDeveloper get
bool PlayerIsTrusted get
SColor ThemeColor1 get
SColor ThemeColor2 get
SColor ThemeColor3 get
SColor ThemeColor4 get
onComplete
Closure (Callback)
onComplete is a function that will be called on completion with SUserRegions as a parameter. onComplete(SUserRegions)
onComplete
Closure (Callback)
onComplete is a function that will be called on completion with a List of SOutfit as a parameter.
SColor get
function GetUserRegionsComplete(SUserRegions)
--
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)--Make's a UIText show this Grid's current Subscription Tier
textObject = Space.Host.GetReference("TheTextReference") --add to References section in Scripting Runtime
function GetUserRegionsComplete(SUserRegions)
local r = SUserRegions.SubscriptionTier
text.UIText.Text = r
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)Space.Grid.GetRegionTexture(AnSPublicRegionObject,OnCompleteFunction)
--see below example--When this object is clicked, it's material becomes the Region Texture of the user's first region
thisObject = Space.Host.ExecutingObject
function GetTextureComplete(textureResource)
thisObject.Renderer.Material.SetTexture("_MainTex",textureResource)
end
function GetUserRegionsComplete(SUserRegions)
r = SUserRegions.AvailableRegions
Space.Grid.GetRegionTexture(r[1],GetTextureComplete)
end
function OnClickFunction()
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)function OnGetOutfitsComplete(TableSOutfits)
--
end
Space.Grid.GetOutfits(OnGetOutfitsComplete)isWhiteLabel = Space.Grid.IsWhiteLabel--Clicking this object will turn it green color if this grid is white-label
--and will turn it red color if not
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if Space.Grid.IsWhiteLabel then
thisObject.Renderer.Material.SetColor("_Color",Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color",Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)isAdmin = Space.Grid.PlayerIsAdmin--Clicking this object will turn it green color if your grid role is Admin
--and will turn it red color if not
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if Space.Grid.PlayerIsAdmin then
thisObject.Renderer.Material.SetColor("_Color",Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color",Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)isModerator = Space.Grid.PlayerIsModerator--Clicking this object will turn it green color if your grid role is Moderator
--and will turn it red color if not
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if Space.Grid.PlayerIsModerator then
thisObject.Renderer.Material.SetColor("_Color",Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color",Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)isDeveloper = Space.Grid.PlayerIsDeveloper--Clicking this object will turn it green color if your grid role is Developer
--and will turn it red color if not
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if Space.Grid.PlayerIsDeveloper then
thisObject.Renderer.Material.SetColor("_Color",Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color",Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)isTrusted = Space.Grid.PlayerIsTrusted--Clicking this object will turn it green color if your grid role is Trusted
--and will turn it red color if not
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
if Space.Grid.PlayerIsTrusted then
thisObject.Renderer.Material.SetColor("_Color",Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color",Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)themeColor1 = Space.Grid.ThemeColor1themeColor2 = Space.Grid.ThemeColor2themeColor3 = Space.Grid.ThemeColor3themeColor4 = Space.Grid.ThemeColor4textColor1 = Space.Grid.TextColor1textColor2 = Space.Grid.TextColor2gridName = Space.Grid.Name--Clicking this object will populate a UIText field with the current Grid's Name
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("TheTextReference")
function OnClickFunction()
local gridName = Space.Grid.Name
textObject.UIText.Text = gridName
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunctionsiteUrl = Space.Grid.SiteURL--Clicking this object will populate a UIText field with the current Grid's Site URL
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("TheTextReference")
function OnClickFunction()
local siteURL = Space.Grid.SiteURL
textObject.UIText.Text = siteURL
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunctiondefaultRegion = Space.Grid.DefaultRegion--Clicking this object will teleport the user to the grid's Default Region
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
local defaultRegion = Space.Grid.DefaultRegion
Space.PlayerAvatar.Teleport(defaultRegion)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)avatars = Space.Grid.Avatars--Clicking this object will populate a UIText field with the current Grid's Avatars
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("TheTextReference")
function OnClickFunction()
local avatars = Space.Grid.Avatars
av = json.serialize(avatars)
textObject.UIText.Text = av
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction) orientationRegion = Space.Grid.OrientationRegion--Clicking this object will teleport the user to the grid's Orientation Region
thisObject = Space.Host.ExecutingObject
function OnClickFunction()
local orientationRegionRegion = Space.Grid.OrientationRegion
Space.PlayerAvatar.Teleport(orientationRegion)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)string TypeName (DynValue dv)
Return the type name of the value.
bool TrackingAllowed (string key)
Returns true on white-label grids when the user has opted into tracking for the given key. Always returns false on the main grid.
void TrackingRequest (string key, string privacynotice, Closure callback, bool force=false)
Displays a consent prompt (EULA-style) asking the user to allow tracking for a given key. On white-label grids, stores the user's choice and invokes the callback with a boolean indicating consent. On the main grid, this does nothing.
GetResource (string name)
Returns a reference to a SResource using it's Resource name.
void LogEvent (string eventName, float value, position)
Logs an analytics event to the server on white-label grids.
void Log (DynValue text, bool logToFile=false) void Log (string text, bool logToFile=false)
Log a message to console.
Inventory get
Allows access to the users inventory
Persistence get
Stores information between user sessions, and for other users
Scene get
Allows access to the current scene graph (objects and avatars in the scene, and other information)
Grid get
Property Description
Host get
Access information about the current scripting runtime host
Physics get
Call physics-related commands, and variables, such as raycasting
Math get
Math related functions (Sin, Cos, Tan, etc)
String get
Miscellaneous additional string functions (e.g. MD5Sum)
Input get
Input device related functions (mouse position, keyboard state)
Camera get
Take and control the users camera
WebServices get
Call remote web services to designated hosts (will not work with arbitrary domains, see page for details)
Network get
Send data to other clients through the region server
PostFX get
Property Description
SAudioAnalyser AudioAnalyser get
Property Description
STween Tween get
Property Description
UI get
Property Description
Dialogues get
Property Description
Shared get
Property Description
Quests get
Property Description
Economy get
Property Description
Groups get
Property Description
SActivity Activity get
Property Description
RenderSettings get
Property Description
Profile get
Property Description
Photos get
Property Description
Videos get
Property Description
SMusicDirectory MusicDirectory get
Property Description
SJourney Journey get
Property Description
SGameTester GameTester get
Property Description
string RuntimeType get
Return current RuntimeType name.
string Platform get
Return current platform name.
string SessionID get
Return current SessionID.
bool InEditor get
Return true if in unity editor.
int Version get
Returns the numeric build version of the viewer (for programmatic comparisons). In the Unity Editor this returns int.MaxValue; if unknown at runtime it returns -1.
string FullVersionString get
Returns the full build version display string tied to release notes (e.g., "2025.6f210"). Best for user-facing display and logging.
[] Resources get
Property Description
float Time get
Returns time at the beginning of this frame.
string ServerTime get
Returns current server time.
string LocalTime get
Returns current local time.
float LoginTime get
Returns how long player has been logged in (in seconds).
int ServerTimeUnix get
Returns the server time unix timestamp.
int LocalTimeUnix get
Returns the local time unix timestamp.
float DeltaTime get
The completion time in seconds since the last frame.
bool PreviewServer get
Return true if in preview server.
string ComponentName get
The name of this component.
dv
DynValue
key
string
A unique identifier used to store and look up the user's tracking consent.
key
string
A unique identifier used to store and look up the user's tracking consent.
privacynotice
string
The privacy notice text to display in the consent dialog.
callback
Closure
A function invoked with one boolean parameter: true if allowed, false otherwise.
force
bool
name
string
Name of the Resource as set in the Scripting Runtime Component (Resources section)
eventName
string
The name of the analytics event.
value
float
A numeric value associated with the event.
position
SVector
A world position to associate with the event.
typeName = Space.TypeName("123")isTrackingAllowed = Space.TrackingAllowed('3423423423423')If true, show the prompt even if a stored decision exists. Defaults to false.
-- Request consent (white-label only). The callback receives a boolean 'allowed'.
Space.TrackingRequest('24234234234234', 'A notice message', function(allowed)
if allowed then
Space.Log("Tracking allowed")
else
Space.Log("Tracking denied")
end
end)
-- or force re-prompt even if a decision was saved previously:
Space.TrackingRequest('24234234234234', 'A notice message', function(allowed) end, true)aResource = Space.GetResource("ResourceName")Space.LogEvent('event name', 2.0, Vector.New(0,0,0) )Space.Log(Color.Blue)
--or
Space.Log("Log")
--or
Space.Log("Log",true)inventory = Space.Inventorypersistence = Space.Persistencescene = Space.Scenegrid = Space.Gridhost = Space.Hostphysics = Space.PhysicsSpace.Math.Ceil(4.0)Space.String.GetBytes("some data")Space.Input.Vibrate(1,1,false)obj = Space.Host.ExecutingObject
Space.Camera.LockCamera (obj)Space.WebServices.GetImage("example.com/mrlee.jpg")Space.Network.SubscribeToNetwork("helloworld", gotAMessageFunction)Space.PostFXSpace.AudioAnalyserSpace.Tweenui = Space.UIdialogues = Space.Dialoguesshared = Space.Sharedquests = Space.Questseconomy = Space.Economygroups = Space.Groupsactivity = Space.ActivityrenderSettings = Space.RenderSettingsprofile = Space.Profilephotos = Space.Photosvideos = Space.VideosmusicDirectory = Space.MusicDirectoryjourney = Space.JourneygameTester = Space.GameTesterruntimeType = Space.RuntimeTypeplatform = Space.PlatformsessionID = Space.SessionIDisInEditor = Space.InEditor--the below script checks if we are in Unity editor or in SS
--this way we can provide an alternative
--(Example: if we're using a function that doesn't work in Unity editor)
thisGameObject = Space.Host.ExecutingObject
if Space.InEditor then
avatarUsername = "Player Name"
else
avatarUsername = Space.Scene.GetAvatar(thisGameObject.Owner).Username --example: this doesn't work in Editor
end
Space.Log(avatarUsername)viewerVersion = Space.VersionviewerVersionString = Space.FullVersionStringtableOfResources = Space.Resources--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]
resources = Space.Resources
for i = 1, #resources do
if resources[i].Type == "AnimationClip" then
Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
break
end
endfloatTime = Space.Time--this script will update a UIText object with the current local time without using a coroutine
--(example: clock )
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
rateUpdate = 1.0
nextUpdate = 0.0
text = Space.Host.GetReference("Text").UIText
OnUpdate = function()
if Space.Time > nextUpdate then
nextUpdate = Space.Time + rateUpdate
text.Text = Space.LocalTime
end
}
Space.Host.ExecutingObject.OnUpdate(OnUpdate)serverTime = Space.ServerTime--this script will update a UIText object with the current server time (UTC)
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.ServerTime
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)localTime = Space.LocalTime--this script will update a UIText object with the current local time
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.LocalTime
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)loginTime = Space.LoginTime--this script will update a UIText object with how long the user has been logged in (in seconds)
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.LoginTime
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)serverTimeUnix = Space.ServerTimeUnix--this script will update a UIText object with the current server time unix timestamp
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.ServerTimeUnix
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)localTimeUnix = Space.LocalTimeUnix--this script will update a UIText object with the current local time unix timestamp
--(example: clock)
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
co = function()
while true do
text.Text = Space.LocalTimeUnix
coroutine.yield(1)
end
end
Space.Host.StartCoroutine(co)deltaTime = Space.DeltaTime--the below script rotates an object around Y axis but uses DeltaTime
--to make sure it's not dependant on client's Framerate (FPS)
--this way the object rotates per second not per frame
--(Example: Important movement in OnUpdate)
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
currentY = thisGameObject.WorldRotation.EulerAngles.Y
newRotation = Quaternion.Euler(0, currentY + 1 * Space.DeltaTime, 0) --We multiplied 1 by Space.DeltaTime
thisGameObject.WorldRotation = newRotation
end
thisGameObject.OnUpdate(OnUpdate)isInPreview = Space.PreviewServer--this script will update a UIText object with "preview" or "live" depending
--whether we are on preview server or live server
--[UIText object needs to be added to the references section in the scripting runtime with name "Text"]
text = Space.Host.GetReference("Text").UIText
OnUpdate = function()
if Space.PreviewServer then
text.Text = "Preview"
else
text.Text = "Live"
end
end
Space.Host.ExecutingObject.OnUpdate(OnUpdate)componentName = Space.ComponentNamevoid (string name, SResource dir)
void (string name, float dir)
void (string name, SColor dir)
void (string name, SVector dir)
int get set
SMaterial get set
float get set
float get set
float get set
int get set
float get set
SColor get set
float get set
void SetGlobalShaderTexture (string name, SResource dir)
Set a global texture property.
void SetGlobalShaderFloat (string name, float dir)
Set a global float property for all shaders.
void SetGlobalShaderColor (string name, SColor dir)
Set a global color property for all shaders.
void SetGlobalShaderVector (string name, SVector dir)
Set a global color property for all shaders.
int DefaultReflectionResolution get set
Cubemap resolution for default reflection.
SMaterial Skybox get set
The global skybox to use.
float FlareFadeSpeed get set
The fade speed of all flares in the Scene.
float FlareStrength get set
The intensity of all flares in the Scene.
float HaloStrength get set
Size of the light halos.
int ReflectionBounces get set
The number of times a reflection includes other reflections.
float ReflectionIntensity get set
How much the skybox / custom cubemap reflection affects the Scene.
SColor SubtractiveShadowColor get set
The color used for the sun shadows in the Subtractive lightmode.
float AmbientIntensity get set
How much the light from the Ambient Source affects the Scene.
SColor AmbientLight get set
Flat ambient lighting color.
SColor AmbientGroundColor get set
Ambient lighting coming from below.
SColor AmbientEquatorColor get set
Ambient lighting coming from the sides.
SColor AmbientSkyColor get set
Ambient lighting coming from above.
int AmbientMode get set
Ambient lighting mode. Skybox = 1. Trilight = 2. Flat = 3. Custom = 4.
float FogEndDistance get set
The ending distance of linear fog.
float FogStartDistance get set
The starting distance of linear fog.
float FogDensity get set
The density of the exponential fog.
SColor FogColor get set
The color of the fog.
int FogMode get set
Ambient lighting mode. Linear = 1. Exponential = 2. ExponentialSquared = 3.
bool Fog get set
Whether Fog is enabled
float AmbientSkyboxAmount get set
How much the light from the Ambient Source affects the Scene.
int DefaultReflectionMode get set
Ambient lighting mode. Skybox = 0. Custom = 1.
Space.RenderSettings.SetGlobalShaderTexture("_TestTex",Space.Resources[1])Space.RenderSettings.SetGlobalShaderFloat("_Mult",1)Space.RenderSettings.SetGlobalShaderFloat("_TestColor",Color.Red)Space.RenderSettings.SetGlobalShaderFloat("_TestVector",Vector.One)Space.RenderSettings.DefaultReflectionResolution=256--the below script will make a slider change the Render Setting's Cube Map Resolution
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.DefaultReflectionResolution = slider.Value * 4096 -- from 0 to 40906
end
slider.OnValueChanged(OVC)Space.RenderSettings.Skybox=Space.Resources[1].AsMaterial--clicking this object will toggle between two Skyboxes
--[Add 2 materials to the first two Resource slots in Scripting Runtime component]
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
if Space.RenderSettings.Skybox==Space.Resources[1].AsMaterial then
Space.RenderSettings.Skybox=Space.Resources[2].AsMaterial
else
Space.RenderSettings.Skybox=Space.Resources[1].AsMaterial
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.FlareFadeSpeed=5--the below script will make a slider change the Render Setting's Flare Fade Speed
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.FlareFadeSpeed = slider.Value * 5 -- from 0 to 5
end
slider.OnValueChanged(OVC)Space.RenderSettings.FlareStrength=1--the below script will make a slider change the Render Setting's Flare Strength
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.FlareStrength = slider.Value * 5 -- from 0 to 5
end
slider.OnValueChanged(OVC)Space.RenderSettings.HaloStrength=1--the below script will make a slider change the Render Setting's Halo Strength
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.HaloStrength = slider.Value * 5 -- from 0 to 5
end
slider.OnValueChanged(OVC)Space.RenderSettings.ReflectionBounces=5--the below script will make a slider change the Render Setting's Reflection Bounces
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.ReflectionBounces = slider.Value * 5 -- from 0 to 5
end
slider.OnValueChanged(OVC)Space.RenderSettings.ReflectionIntensity=1--the below script will make a slider change the Render Setting's Reflection Intensity
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.ReflectionIntensity = slider.Value * 5 -- from 0 to 5
end
slider.OnValueChanged(OVC)Space.RenderSettings.SubtractiveShadowColor=Color.Red--clicking the object will open a color picker that changes the Subtractive Shadow Color
thisGameObject = Space.Host.ExecutingObject
originalColor = Space.RenderSettings.SubtractiveShadowColor
OnChange = function(SColor)
Space.RenderSettings.SubtractiveShadowColor = SColor
end
OnSelect = function(SColor)
Space.RenderSettings.SubtractiveShadowColor = SColor
end
OnCancel = function()
Space.RenderSettings.SubtractiveShadowColor = originalColor
end
OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.AmbientIntensity = 1--the below script will make a slider change the Render Setting's Ambient Intensity
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.AmbientIntensity = slider.Value * 5 -- from 0 to 5
end
slider.OnValueChanged(OVC)Space.RenderSettings.AmbientLight=Color.Blue--clicking the object will open a color picker that changes the Ambient Light Color
thisGameObject = Space.Host.ExecutingObject
originalColor = Space.RenderSettings.AmbientLight
OnChange = function(SColor)
Space.RenderSettings.AmbientLight = SColor
end
OnSelect = function(SColor)
Space.RenderSettings.AmbientLight = SColor
end
OnCancel = function()
Space.RenderSettings.AmbientLight = originalColor
end
OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.AmbientGroundColor=Color.Green--clicking the object will open a color picker that changes the Ambient Ground Color
thisGameObject = Space.Host.ExecutingObject
originalColor = Space.RenderSettings.AmbientGroundColor
OnChange = function(SColor)
Space.RenderSettings.AmbientGroundColor = SColor
end
OnSelect = function(SColor)
Space.RenderSettings.AmbientGroundColor = SColor
end
OnCancel = function()
Space.RenderSettings.AmbientGroundColor = originalColor
end
OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.AmbientEquatorColor=Color.Green--clicking the object will open a color picker that changes the Ambient Equator Color
thisGameObject = Space.Host.ExecutingObject
originalColor = Space.RenderSettings.AmbientEquatorColor
OnChange = function(SColor)
Space.RenderSettings.AmbientEquatorColor = SColor
end
OnSelect = function(SColor)
Space.RenderSettings.AmbientEquatorColor = SColor
end
OnCancel = function()
Space.RenderSettings.AmbientEquatorColor= originalColor
end
OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.AmbientSkyColor=Color.White--clicking the object will open a color picker that changes the Ambient Sky Color
thisGameObject = Space.Host.ExecutingObject
originalColor = Space.RenderSettings.AmbientSkyColor
OnChange = function(SColor)
Space.RenderSettings.AmbientSkyColor = SColor
end
OnSelect = function(SColor)
Space.RenderSettings.AmbientSkyColor = SColor
end
OnCancel = function()
Space.RenderSettings.AmbientSkyColor = originalColor
end
OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.AmbientMode=1--clicking this object will toggle between 4 Ambient Modes
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
if Space.RenderSettings.AmbientMode==4 then
Space.RenderSettings.AmbientMode=1
else
Space.RenderSettings.AmbientMode = Space.RenderSettings.AmbientMode + 1
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.FogEndDistance=300--the below script will make a slider change the Render Setting's Fog End Distance
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.FogEndDistance = (slider.Value * 170) + 30-- from 30 to 200
end
slider.OnValueChanged(OVC)Space.RenderSettings.FogStartDistance=10--the below script will make a slider change the Render Setting's Fog Start Distance
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.FogStartDistance = (slider.Value * 10) -- from 0 to 10
end
slider.OnValueChanged(OVC)Space.RenderSettings.FogDensity=10--the below script will make a slider change the Render Setting's Fog Density
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.FogDensity = (slider.Value * 10) -- from 0 to 10
end
slider.OnValueChanged(OVC)Space.RenderSettings.FogColor = Color.Red--clicking the object will open a color picker that changes the Fog color
thisGameObject = Space.Host.ExecutingObject
originalColor = Space.RenderSettings.FogColor
OnChange = function(SColor)
Space.RenderSettings.FogColor = SColor
end
OnSelect = function(SColor)
Space.RenderSettings.FogColor = SColor
end
OnCancel = function()
Space.RenderSettings.FogColor = originalColor
end
OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.FogMode=2--clicking this object will toggle between 3 Fog Modes
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
if Space.RenderSettings.FogMode==3 then
Space.RenderSettings.FogMode=1
else
Space.RenderSettings.FogMode = Space.RenderSettings.FogMode + 1
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.Fog=true--clicking this object will toggle enable/disable Fog
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.RenderSettings.Fog = not Space.RenderSettings.Fog
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)Space.RenderSettings.AmbientSkyboxAmount=10--the below script will make a slider change the Render Setting's Ambient Skybox Amount
thisGameObject = Space.Host.ExecutingObject
slider = Space.Host.GetReference("slider").UISlider --add reference to Scripting Runtime
OVC = function()
Space.RenderSettings.AmbientSkyboxAmount = (slider.Value * 10) -- from 0 to 10
end
slider.OnValueChanged(OVC)Space.RenderSettings.DefaultReflectionMode = 1--clicking this object will toggle between two Default Reflection Modes
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
if Space.RenderSettings.DefaultReflectionMode==1 then
Space.RenderSettings.DefaultReflectionMode=0
else
Space.RenderSettings.DefaultReflectionMode=1
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)SColor AmbientLight get set
SColor AmbientGroundColor get set
SColor AmbientEquatorColor get set
SColor AmbientSkyColor get set
SAmbientMode AmbientMode get set
float FogEndDistance get set
float FogStartDistance get set
float FogDensity get set
SColor FogColor get set
SFogMode FogMode get set
bool Fog get set
float AmbientSkyboxAmount get set
SDefaultReflectionMode DefaultReflectionMode get set
Find (string name)
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')
FindID (string id)
Finds a single Game Object using ID and returns it
void MarkObjectTemporary ( obj)
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.
GetAvatar (long id) GetAvatar (string name)
Get reference to an avatar
CreateGameObject (string name) CreateGameObject ( resource)
Creates a game object from the specified resource
void SwitchToInstance (uint id)
Switch to a shard region.
void OnPlayerJoin (Closure e)
Event which fires whenever a player joins the region
void OnPlayerLeave (Closure e)
Event which fires whenever a player leaves the region
void OnEditModeStart (Closure e)
An event which is fired when player enters Room Edit mode
void OnEditModeEnd (Closure e)
An event which is fired when player exits Room Edit mode
void OnEditModeAdd (Closure e)
An event which is fired when object is added during Edit Mode
void OnEditModeRemove (Closure e)
An event which is fired when object is deleted during Edit Mode
PlayerAvatar get
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.
[] Avatars get
Returns a list of Avatars in the scene
List< > AllAvatars get
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.
int Population get
Property Description
[] Objects get
Returns a list of Objects in the scene. IMPORTANT: This function is slow, you should cache the result and avoid calling this every frame.
string Name get
Returns the name of the current region
string Url get
Returns the URL of the current region
long RegionID get
Returns the region ID of current region.
long InstanceID get
Return the instance ID of current region.
long Owner get
Returns the avatar ID of the regions owner
bool PlayerIsOwner get
Returns whether the current player is the owner of the region
bool PlayerIsAdmin get
Does this Player have the Admin role?
bool PlayerIsModerator get
Does this Player have the Moderator role?
bool PlayerIsDeveloper get
Does this Player have the Developer role?
bool PlayerIsTrusted get
Does this Player have the Trusted role?
bool IsInEditMode get
Returns true if current player is in edit mode.
[] Floors get
Return an array of all floors in the region.
[] Landmarks get
Return all Landmarks in the region
bool get
bool get
bool get
bool get
bool get
bool get
SGameObject[] get
SLandmark[] get
SGameObject Find (string name)
SGameObject FindID (string id)
void MarkObjectTemporary (SGameObject obj)
SGameObject CreateGameObject (string name) SGameObject CreateGameObject (SResource resource)
void SwitchToInstance (uint id)
void OnPlayerJoin (Closure e)
void OnPlayerLeave (Closure e)
void OnEditModeStart (Closure e)
void OnEditModeEnd (Closure e)
void OnEditModeAdd (Closure e)
SAvatar PlayerAvatar get
SAvatar[] Avatars get
List< SAvatar > AllAvatars get
int Population get
SGameObject[] Objects get
string Name get
string Url get
long RegionID get
long InstanceID get
e
Closure (Callback)
e(SAvatar)
e
Closure (Callback)
e(long)
void (Closure e)
long get
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. --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.Space.Scene.MarkObjectTemporary(AnObjectReference)theAvatar =Space.Scene.GetAvatar(43)
--or
theAvatar =Space.Scene.GetAvatar("TestUser")Space.Scene.CreateGameObject('NewBall')
--or
Space.Scene.CreateGameObject(Space.Resources[1])--clicking this object will create a GameObject from a resource and place it above our avatar
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
resource = Space.GetResource("Tomato") --add it as resource in your Scripting Runtime component
OnClick = function()
createdObject = Space.Scene.CreateGameObject(resource)
createdObject.WorldPosition = thisPlayer.GameObject.WorldPosition + thisPlayer.GameObject.Up
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)Space.Scene.SwitchToInstance(2)--Place this script in a UIText object and it will
--update itself with the name of the last player joined
function updateText(Av) --we include "Av" here because the event gives us a reference to the Avatar that joined
Space.Host.ExecutingObject.UIText.Text= "Last player joined: " .. Av.Username
end
Space.Scene.OnPlayerJoin(updateText) -- updateText will now be called everytime a player joins function playerLeft(id)
--
end
Space.Scene.OnPlayerLeave(playerLeft) --Place this script in a UIText object and it will
--update itself with the name of the last player left
function updateText(Av) --we include "Av" here because the event gives us a reference to the Avatar that has left
Space.Host.ExecutingObject.UIText.Text= "Last player left: " .. Av.Username
end
Space.Scene.OnPlayerLeave(updateText) -- updateText will now be called every time a player leavesSpace.Scene.OnEditModeStart(AFunctionName)--makes an object become active upon entering edit mode
thisObject = Space.Host.ExecutingObject
targetObject = Space.Host.GetReference("target") --add to references in Scripting Runtime component
function OnEditModeFunction()
targetObject.Active = true
end
Space.Scene.OnEditModeStart(OnEditModeFunction)Space.Scene.OnEditModeEnd(AfunctionName)--makes an object become active upon exiting edit mode
thisObject = Space.Host.ExecutingObject
targetObject = Space.Host.GetReference("target") --add to references in Scripting Runtime component
function OnEditModeFunction()
targetObject.Active = false
end
Space.Scene.OnEditModeEnd(OnEditModeFunction)Space.Scene.OnEditModeAdd(AFunctionName)--prints the total number of objects in the scene whenever a new object is added in edit mode
function OnEditModeFunction()
Space.Log(#Space.Scene.Objects)
end
Space.Scene.OnEditModeAdd(OnEditModeFunction)Space.Scene.OnEditModeRemove(AFunctionName)--prints the total number of objects in the scene whenever a new object is removed in edit mode
function OnEditModeFunction()
Space.Log(#Space.Scene.Objects)
end
Space.Scene.OnEditModeRemove(OnEditModeFunction) CurrentPlayer = Space.Scene.PlayerAvatar avatars = Space.Scene.Avatars --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.ExecutingObject
OnClick = function()
Avatars = Space.Scene.Avatars
if #Avatars > 0 then
for var=1, #Avatars do
local ID = Avatars[var].ID
local Username = Avatars[var].Username
local Title = Avatars[var].Title
if Title == "" then Title = "None" end
Space.Log("ID: " .. ID .. ", Username: " .. Username .. ", Title: " .. Title)
end
else
Space.Log("No Avatars")
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to print all avatars' information"
thisGameObject.Clickable.OnClick(OnClick) local avatars=Space.Scene.AllAvatars
Space.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.ExecutingObject
OnClick = function()
allAvatars = Space.Scene.AllAvatars
for var=1, #allAvatars do
local ID = allAvatars[var].ID
local Username = allAvatars[var].Username
local Title = allAvatars[var].Title
if Title == "" then Title = "None" end
Space.Log("ID: " .. ID .. ", Username: " .. Username .. ", Title: " .. Title)
end
end
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to print all avatars' information"
thisGameObject.Clickable.OnClick(OnClick) currentPopulation = Space.Scene.Population 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.ExecutingObject
OnClickFunction = function()
local objects = Space.Scene.Objects
for i=1, #objects, 1 do
Space.Log(objects[i].Name)
end
end
thisObject.AddClickable()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.ExecutingObject
OnClick = function()
Space.Log("We are in X Region")
end
if Space.Scene.Name == "X Region" then
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)
endRegionUrl = Space.Scene.Url --the URL of this region will be placed in a UIText upon loading
--and also printed if this object is clicked
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") -- add to scripting runtime references
function OnClick()
Space.Log(Space.Scene.Url)
end
textObject.UIText.Text = Space.Scene.Url
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)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 clicked
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") -- add to scripting runtime references
function OnClick()
Space.Log(Space.Scene.RegionID)
end
textObject.UIText.Text = Space.Scene.RegionID
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)instanceID = Space.Scene.InstanceID--the RegionID of this region will be placed in a UIText upon loading
--and also printed if this object is clicked
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") -- add to scripting runtime references
function OnClick()
Space.Log(Space.Scene.InstanceID)
end
textObject.UIText.Text = Space.Scene.InstanceID
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)RegionOwner = Space.Scene.Owner--this script will make this object only clickable for the region owner
thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar
OnClick = function()
Space.Log("Do Something")
end
if thisPlayer.ID == Space.Scene.Owner then
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)
endisOwner = Space.Scene.PlayerIsOwner --this script will make the object a clickable, but only if player is region owner
--(Example: Access control)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.Log("this click was only possible because you are a region Owner")
end
if Space.Scene.PlayerIsOwner then
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me"
thisGameObject.Clickable.OnClick(OnClick)
endSpace.Scene.PlayerIsAdmin--this script will make the object a clickable, but only if player is region Admin
--(Example: Access control)
thisGameObject = Space.Host.ExecutingObject
OnClick = function()
Space.Log("this click was only possible because you are a region Admin")
end
if Space.Scene.PlayerIsAdmin then
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me Admin"
thisGameObject.Clickable.OnClick(OnClick)
endplayerIsModerator = 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.ExecutingObject
OnClick = function()
Space.Log('this click was only possible because you are Moderator in this region')
end
if Space.Scene.PlayerIsModerator then
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me Moderator"
thisGameObject.Clickable.OnClick(OnClick)
endplayerIsDeveloper = Space.Scene.PlayerIsDeveloperplayerIsTrusted = 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.ExecutingObject
OnClick = function()
Space.Log("this click was only possible because you are Trusted in this region")
end
if Space.Scene.PlayerIsTrusted then
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click me Trusted"
thisGameObject.Clickable.OnClick(OnClick)
endSpace.Log(Space.Scene.IsInEditMode)--makes an object only active when this player is in Edit Mode
thisObject = Space.Host.ExecutingObject
targetObject = Space.Host.GetReference("target") --add to references in Scripting Runtime component
function OnUpdateFunction()
targetObject.Active = Space.Scene.IsInEditMode
end
thisObject.OnUpdate(OnUpdateFunction)for i=1,#Space.Scene.Floors do
Space.Log(Space.Scene.Floors[i].Name)
end
--print all floor names.example 2 local landmark = Space.Scene.Landmarks
for i = 1,#landmark do
if landmark[i].Type == LandmarkType.LandingZone then
Space.Log("LandingZone")
end
Space.Log(landmark[i].Name .. " ".. landmark[i].Position.ToString())
end