LogoLogo
Scripting DocsSupport
Scripting
Scripting
  • Sinespace Scripting Documentation
  • Client Scripting
    • Viewer
      • SDialogues
      • SInput
      • SShared
      • SUI
    • Network
      • SChat
      • SNetwork
      • SPhotos
      • SVideos
      • SWebService
    • Player
      • SEconomy
      • SGroup
      • SInventory
      • SProfile
      • SQuests
    • Region
      • SCameraManager
      • SGrid
      • SHost
      • SPersistence
      • SPhysics
      • SPostFX
      • SScene
      • SScript
      • SRenderSettings
    • Components
      • SAnimation
      • SAnimator
      • SAudioReactiveAnimation
      • SAudioReactiveBase
      • SAudioReactiveLight
      • SAudioReactiveMaterial
      • SAudioReactiveParticleSystem
      • SAudioReactiveTransform
      • SAudioSource
      • SBoxCollider
      • SBrowserSurface
      • SCamera
      • SCanvasGroup
      • SCapsuleCollider
      • SCharacterController
      • SClickable
      • SCloth
      • SCollider
      • SContentSizeFitter
      • SEmbeddedVideo
      • SEventCalendar
      • SFurniture
      • SGraphicRaycaster
      • SHingeJoint
      • SLight
      • SLineRenderer
      • SMeshRenderer
      • SModularVehicle
      • SNavMeshAgent
      • SNavMeshObstacle
      • SNetworking
      • SParticleSystem
      • SPlayableDirector
      • SPostProcessVolume
      • SRectTransform
      • SReflectionProbe
      • SRenderer
      • SRigidbody
      • SRoomFloor
      • SSceneBackgroundMusic
      • SScriptingData
      • SScriptingEvents
      • SScriptingResources
      • SScriptingRuntime
      • SSeat
      • SSkinnedMeshRenderer
      • SSphereCollider
      • SStateMachine
      • STerrain
      • STrailRenderer
      • SUIButton
      • SUICanvas
      • SUIDropdown
      • SUIImage
      • SUIInputField
      • SUILayout
      • SUIRawImage
      • SUIScrollbar
      • SUISlider
      • SUIText
      • SUIToggle
      • SUIToolTipHint
      • SVirtualCamera
      • SVoiceZone
    • Types
      • SAnimationState
      • SAnimatorStateInfo
      • SAvatar
      • SAvatarAppearance
      • SChatMessage
      • SColor
      • SCommandBuffer
      • SDateTime
      • SGameObject
      • SGenre
      • SGroupInfo
      • SInventoryItem
      • SJointLimits
      • SJointMotor
      • SJointSpring
      • SLandmark
      • SLayerMask
      • SMaterial
      • SMath
      • SMusicDirectory
      • SMusicStation
      • SMusicStationList
      • SNetworkMessageLua
      • SOutfit
      • SParticle
      • SPhysicsHit
      • SPublicRegion
      • SQuaternion
      • SRay
      • SRect
      • SResource
      • SScore
      • SScoreRank
      • SString
      • SSubRegion
      • STrackInfo
      • STuneIn
      • SUIRaycastResult
      • SUserRegions
      • SVector
      • SUserProfile
      • SSocialMedia
      • SWebResponse
  • Server Scripting
    • Library
      • SMath
    • Network
      • SShared
      • SWebservice
    • Region
      • SAvatar
      • SCell
      • SObject
      • SParcel
      • SParcelManager
      • SRegionScript
      • SScene
    • Storage
      • SDatabase
  • Guides
    • Persistence
    • Server Scripts
  • Sample Projects
    • Smart Lights
    • Trivia Box
  • Changelog
    • API Changelog
  • Support
    • Report An Issue
Powered by GitBook

Sinespace® is a registered trademark of Sine Wave Entertainment Ltd, All Rights Reserved.

On this page
  • Functions
  • TypeName
  • TrackingAllowed
  • TrackingRequest
  • GetResource
  • LogEvent
  • Log
  • Properties
  • Inventory
  • Persistence
  • Scene
  • Grid
  • Host
  • Physics
  • Math
  • String
  • Input
  • Camera
  • WebServices
  • Network
  • PostFX
  • AudioAnalyser
  • Tween
  • UI
  • Dialogues
  • Shared
  • Quests
  • Economy
  • Groups
  • Activity
  • RenderSettings
  • Profile
  • Photos
  • Videos
  • MusicDirectory
  • Journey
  • GameTester
  • RuntimeType
  • Platform
  • SessionID
  • InEditor
  • Version
  • Resources
  • Time
  • ServerTime
  • LocalTime
  • LoginTime
  • ServerTimeUnix
  • LocalTimeUnix
  • DeltaTime
  • PreviewServer
  • ComponentName

Was this helpful?

Export as PDF
  1. Client Scripting
  2. Region

SScript

Functions

TypeName

string TypeName (DynValue dv)

Return the type name of the value.

Parameter
Type
Description

dv

DynValue

typeName = Space.TypeName("123")

TrackingAllowed

bool TrackingAllowed (string key)

Function Description

Parameter
Type
Description

isTrackingAllowed = Space.TrackingAllowed('3423423423423')

TrackingRequest

void TrackingRequest (string key, string privacynotice, Closure callback, bool force=false)

Function Description

Parameter
Type
Description

Space.TrackingRequest('24234234234234', 'A notice message', ACallBackFunction)
--or 
Space.TrackingRequest('24234234234234', 'A notice message', ACallBackFunction, true)

GetResource

Returns a reference to a SResource using it's Resource name.

Parameter
Type
Description

name

string

Name of the Resource as set in the Scripting Runtime Component (Resources section)

aResource = Space.GetResource("ResourceName")

LogEvent

Function Description

Parameter
Type
Description

Space.LogEvent('event name', 2.0, Vector.New(0,0,0) )

Log

void Log (DynValue text, bool logToFile=false) void Log (string text, bool logToFile=false)

Log a message to console.

Parameter
Type
Description

Space.Log(Color.Blue)
--or
Space.Log("Log")
--or
Space.Log("Log",true)

Properties

Inventory

Allows access to the users inventory

inventory  = Space.Inventory

Persistence

Stores information between user sessions, and for other users

persistence = Space.Persistence

Scene

Allows access to the current scene graph (objects and avatars in the scene, and other information)

scene = Space.Scene

Grid

Property Description

grid = Space.Grid

Host

Access information about the current scripting runtime host

host = Space.Host

Physics

Call physics-related commands, and variables, such as raycasting

physics = Space.Physics

Math

Math related functions (Sin, Cos, Tan, etc)

Space.Math.Ceil(4.0)

String

Miscellaneous additional string functions (e.g. MD5Sum)

Space.String.GetBytes("some data")

Input

Input device related functions (mouse position, keyboard state)

Space.Input.Vibrate(1,1,false)

Camera

Take and control the users camera

obj = Space.Host.ExecutingObject
Space.Camera.LockCamera (obj)

WebServices

Call remote web services to designated hosts (will not work with arbitrary domains, see page for details)

Space.WebServices.GetImage("example.com/mrlee.jpg")

Network

Send data to other clients through the region server

Space.Network.SubscribeToNetwork("helloworld", gotAMessageFunction)

PostFX

Property Description

Space.PostFX

AudioAnalyser

SAudioAnalyser AudioAnalyser get

Property Description

Space.AudioAnalyser

Tween

STween Tween get

Property Description

Space.Tween

UI

Property Description

ui = Space.UI

Dialogues

Property Description

dialogues = Space.Dialogues

Shared

Property Description

shared = Space.Shared

Quests

Property Description

quests = Space.Quests

Economy

Property Description

economy = Space.Economy

Groups

Property Description

groups = Space.Groups

Activity

SActivity Activity get

Property Description

activity = Space.Activity

RenderSettings

Property Description

renderSettings = Space.RenderSettings

Profile

Property Description

profile = Space.Profile

Photos

Property Description

photos = Space.Photos

Videos

Property Description

videos = Space.Videos

MusicDirectory

SMusicDirectory MusicDirectory get

Property Description

musicDirectory = Space.MusicDirectory

Journey

SJourney Journey get

Property Description

journey = Space.Journey

GameTester

SGameTester GameTester get

Property Description

gameTester = Space.GameTester

RuntimeType

string RuntimeType get

Return current RuntimeType name.

runtimeType = Space.RuntimeType

Platform

string Platform get

Return current platform name.

platform = Space.Platform

SessionID

string SessionID get

Return current SessionID.

sessionID = Space.SessionID

InEditor

bool InEditor get

Return true if in unity editor.

isInEditor = 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)

Version

int Version get

Returns the version of the viewer this script is running in

viewerVersion = Space.Version

Resources

Property Description

tableOfResources = 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
  end

Time

float Time get

Returns time at the beginning of this frame.

floatTime = 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

string ServerTime get

Returns current server time.

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

string LocalTime get

Returns current local time.

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

float LoginTime get

Returns how long player has been logged in (in seconds).

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

int ServerTimeUnix get

Returns the server time unix timestamp.

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

int LocalTimeUnix get

Returns the local time unix timestamp.

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

float DeltaTime get

The completion time in seconds since the last frame.

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)

PreviewServer

bool PreviewServer get

Return true if in preview server.

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

string ComponentName get

The name of this component.

componentName = Space.ComponentName
PreviousSSceneNextSRenderSettings

Last updated 2 years ago

Was this helpful?

GetResource (string name)

void LogEvent (string eventName, float value, position)

Inventory get

Persistence get

Scene get

Grid get

Host get

Physics get

Math get

String get

Input get

Camera get

WebServices get

Network get

PostFX get

UI get

Dialogues get

Shared get

Quests get

Economy get

Groups get

RenderSettings get

Profile get

Photos get

Videos get

[] Resources get

SResource
SVector
SInventory
SPersistence
SScene
SGrid
SHost
SPhysics
SMath
SString
SInput
SCameraManager
SWebService
SNetwork
SPostFX
SUI
SDialogues
SShared
SQuests
SEconomy
SGroup
SRenderSettings
SProfile
SPhotos
SVideos
SResource