Breakroom is now Sinewave Campus. Book a meeting

SScript

ClientScène
Dans cette classeTypeName
  1. Fonctions
  2. TypeName
  3. TrackingAllowed
  4. TrackingRequest
  5. GetResource
  6. LogEvent
  7. Log
  8. Propriétés
  9. Inventory
  10. Persistence
  11. Scene
  12. Grid
  13. Host
  14. Physics
  15. Math
  16. String
  17. Input
  18. Camera
  19. WebServices
  20. Network
  21. PostFX
  22. AudioAnalyser
  23. Tween
  24. UI
  25. Dialogues
  26. Shared
  27. Quests
  28. Economy
  29. Groups
  30. Activity
  31. RenderSettings
  32. Profile
  33. Photos
  34. Videos
  35. MusicDirectory
  36. Journey
  37. GameTester
  38. RuntimeType
  39. Platform
  40. SessionID
  41. InEditor
  42. Version
  43. FullVersionString
  44. Resources
  45. Time
  46. ServerTime
  47. LocalTime
  48. LoginTime
  49. ServerTimeUnix
  50. LocalTimeUnix
  51. DeltaTime
  52. PreviewServer
  53. ComponentName
Membres 51
FonctionTypeNameReturn the type name of the value.
FonctionTrackingAllowedReturns true on white-label grids when the user has opted into tracking for the given key.
FonctionTrackingRequestDisplays a consent prompt (EULA-style) asking the user to allow tracking for a given key.
FonctionGetResourceReturns a reference to a SResource using it's Resource name.
FonctionLogEventLogs an analytics event to the server on white-label grids.
FonctionLogLog a message to console.
PropriétéInventoryAllows access to the users inventory
PropriétéPersistenceStores information between user sessions, and for other users
PropriétéSceneAllows access to the current scene graph (objects and avatars in the scene, and other information)
PropriétéGrid–
PropriétéHostAccess information about the current scripting runtime host
PropriétéPhysicsCall physics-related commands, and variables, such as raycasting
PropriétéMathMath related functions (Sin, Cos, Tan, etc)
PropriétéStringMiscellaneous additional string functions (e.g. MD5Sum)
PropriétéInputInput device related functions (mouse position, keyboard state)
PropriétéCameraTake and control the users camera
PropriétéWebServicesCall remote web services to designated hosts (will not work with arbitrary domains, see page for details)
PropriétéNetworkSend data to other clients through the region server
PropriétéPostFX–
PropriétéAudioAnalyser–
PropriétéTween–
PropriétéUI–
PropriétéDialogues–
PropriétéShared–
PropriétéQuests–
PropriétéEconomy–
PropriétéGroups–
PropriétéActivity–
PropriétéRenderSettings–
PropriétéProfile–
PropriétéPhotos–
PropriétéVideos–
PropriétéMusicDirectory–
PropriétéJourney–
PropriétéGameTester–
PropriétéRuntimeTypeReturn current RuntimeType name.
PropriétéPlatformReturn current platform name.
PropriétéSessionIDReturn current SessionID.
PropriétéInEditorReturn true if in unity editor.
PropriétéVersionReturns the numeric build version of the viewer (for programmatic comparisons).
PropriétéFullVersionStringReturns the full build version display string tied to release notes (e.g., "2025.6f210").
PropriétéResources–
PropriétéTimeReturns time at the beginning of this frame.
PropriétéServerTimeReturns current server time.
PropriétéLocalTimeReturns current local time.
PropriétéLoginTimeReturns how long player has been logged in (in seconds).
PropriétéServerTimeUnixReturns the server time unix timestamp.
PropriétéLocalTimeUnixReturns the local time unix timestamp.
PropriétéDeltaTimeThe completion time in seconds since the last frame.
PropriétéPreviewServerReturn true if in preview server.
PropriétéComponentNameThe name of this component.

Fonctions​

TypeName​

string TypeName(DynValue dv)

Return the type name of the value.

Paramètres

NomTypeValeur par défaut
dvDynValue–

Valeurs de retour

string

Exemple

Lua
typeName = Space.TypeName("123")

TrackingAllowed​

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.

Paramètres

ParamètreTypeDescription
keystringA unique identifier used to store and look up the user's tracking consent.

Valeurs de retour

bool

Exemple

Lua
isTrackingAllowed = Space.TrackingAllowed('3423423423423')

TrackingRequest​

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.

Paramètres

ParamètreTypeDescription
keystringA unique identifier used to store and look up the user's tracking consent.
privacynoticestringThe privacy notice text to display in the consent dialog.
callbackClosureA function invoked with one boolean parameter: true if allowed, false otherwise.
forceboolIf true, show the prompt even if a stored decision exists. Defaults to false.

Valeurs de retour

void

Exemple

Lua
-- 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)

GetResource​

SResource GetResource(string name)

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

Paramètres

ParamètreTypeDescription
namestringName of the Resource as set in the Scripting Runtime Component (Resources section)

Valeurs de retour

SResource

Exemple

Lua
aResource = Space.GetResource("ResourceName")

LogEvent​

void LogEvent(string eventName, float value, SVector position)

Logs an analytics event to the server on white-label grids.

Paramètres

ParamètreTypeDescription
eventNamestringThe name of the analytics event.
valuefloatA numeric value associated with the event.
positionSVectorA world position to associate with the event.

Valeurs de retour

void

Exemple

Lua
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.

Paramètres

NomTypeValeur par défaut
textDynValue–
logToFileboolfalse
textstring–

Valeurs de retour

void

Exemple

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

Propriétés​

InventoryLecture seule​

SInventory Inventory {get; }

Allows access to the users inventory

Exemple

Lua
inventory = Space.Inventory

PersistenceLecture seule​

SPersistence Persistence {get; }

Stores information between user sessions, and for other users

Exemple

``` persistence = Space.Persistence ```

SceneLecture seule​

SScene Scene {get; }

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

Exemple

Lua
scene = Space.Scene

GridLecture seule​

SGrid Grid {get; }

Exemple

Lua
grid = Space.Grid

HostLecture seule​

SHost Host {get; }

Access information about the current scripting runtime host

Exemple

Lua
host = Space.Host

PhysicsLecture seule​

SPhysics Physics {get; }

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

Exemple

Lua
physics = Space.Physics

MathLecture seule​

SMath Math {get; }

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

Exemple

Lua
Space.Math.Ceil(4.0)

StringLecture seule​

SString String {get; }

Miscellaneous additional string functions (e.g. MD5Sum)

Exemple

Lua
Space.String.GetBytes("some data")

InputLecture seule​

SInput Input {get; }

Input device related functions (mouse position, keyboard state)

Exemple

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

CameraLecture seule​

SCameraManager Camera {get; }

Take and control the users camera

Exemple

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

WebServicesLecture seule​

SWebService WebServices {get; }

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

Exemple

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

NetworkLecture seule​

SNetwork Network {get; }

Send data to other clients through the region server

Exemple

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

PostFXLecture seule​

SPostFX PostFX {get; }

Exemple

Lua
Space.PostFX

AudioAnalyserLecture seule​

SAudioAnalyser AudioAnalyser {get; }

Exemple

Lua
Space.AudioAnalyser

TweenLecture seule​

STween Tween {get; }

Exemple

Lua
Space.Tween

UILecture seule​

SUI UI {get; }

Exemple

Lua
ui = Space.UI

DialoguesLecture seule​

SDialogues Dialogues {get; }

Exemple

Lua
dialogues = Space.Dialogues

SharedLecture seule​

SShared Shared {get; }

Exemple

Lua
shared = Space.Shared

QuestsLecture seule​

SQuests Quests {get; }

Exemple

Lua
quests = Space.Quests

EconomyLecture seule​

SEconomy Economy {get; }

Exemple

Lua
economy = Space.Economy

GroupsLecture seule​

SGroup Groups {get; }

Exemple

Lua
groups = Space.Groups

ActivityLecture seule​

SActivity Activity {get; }

Exemple

``` activity = Space.Activity ```

RenderSettingsLecture seule​

SRenderSettings RenderSettings {get; }

Exemple

Lua
renderSettings = Space.RenderSettings

ProfileLecture seule​

SProfile Profile {get; }

Exemple

Lua
profile = Space.Profile

PhotosLecture seule​

SPhotos Photos {get; }

Exemple

Lua
photos = Space.Photos

VideosLecture seule​

SVideos Videos {get; }

Exemple

Lua
videos = Space.Videos

MusicDirectoryLecture seule​

SMusicDirectory MusicDirectory {get; }

Exemple

Lua
musicDirectory = Space.MusicDirectory

JourneyLecture seule​

SJourney Journey {get; }

Exemple

Lua
journey = Space.Journey

GameTesterLecture seule​

SGameTester GameTester {get; }

Exemple

Lua
gameTester = Space.GameTester

RuntimeTypeLecture seule​

string RuntimeType {get; }

Return current RuntimeType name.

Exemple

Lua
runtimeType = Space.RuntimeType

PlatformLecture seule​

string Platform {get; }

Return current platform name.

Exemple

Lua
platform = Space.Platform

SessionIDLecture seule​

string SessionID {get; }

Return current SessionID.

Exemple

Lua
sessionID = Space.SessionID

InEditorLecture seule​

bool InEditor {get; }

Return true if in unity editor.

Exemple

Lua
isInEditor = Space.InEditor
Lua
--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)

VersionLecture seule​

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.

Exemple

Lua
viewerVersion = Space.Version

FullVersionStringLecture seule​

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.

Exemple

Lua
viewerVersionString = Space.FullVersionString

ResourcesLecture seule​

SResource[] Resources {get; }

Exemple

Lua
tableOfResources = Space.Resources
Lua
--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

TimeLecture seule​

float Time {get; }

Returns time at the beginning of this frame.

Exemple

Lua
floatTime = Space.Time
Lua
--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)

ServerTimeLecture seule​

string ServerTime {get; }

Returns current server time.

Exemple

Lua
serverTime = Space.ServerTime
Lua
--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)

LocalTimeLecture seule​

string LocalTime {get; }

Returns current local time.

Exemple

Lua
localTime = Space.LocalTime
Lua
--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)

LoginTimeLecture seule​

float LoginTime {get; }

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

Exemple

Lua
loginTime = Space.LoginTime
Lua
--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)

ServerTimeUnixLecture seule​

int ServerTimeUnix {get; }

Returns the server time unix timestamp.

Exemple

Lua
serverTimeUnix = Space.ServerTimeUnix
Lua
--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)

LocalTimeUnixLecture seule​

int LocalTimeUnix {get; }

Returns the local time unix timestamp.

Exemple

Lua
localTimeUnix = Space.LocalTimeUnix
Lua
--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)

DeltaTimeLecture seule​

float DeltaTime {get; }

The completion time in seconds since the last frame.

Exemple

Lua
deltaTime = Space.DeltaTime
Lua
--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)

PreviewServerLecture seule​

bool PreviewServer {get; }

Return true if in preview server.

Exemple

Lua
isInPreview = Space.PreviewServer
Lua
--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)

ComponentNameLecture seule​

string ComponentName {get; }

The name of this component.

Exemple

Lua
componentName = Space.ComponentName