Breakroom is now Sinewave Campus. Book a meeting

SScript

العميلالمشهد
في هذا الصنفTypeName
  1. الدوال
  2. TypeName
  3. TrackingAllowed
  4. TrackingRequest
  5. GetResource
  6. LogEvent
  7. Log
  8. الخصائص
  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
الأعضاء 51
دالةTypeNameReturn the type name of the value.
دالةTrackingAllowedReturns true on white-label grids when the user has opted into tracking for the given key.
دالةTrackingRequestDisplays a consent prompt (EULA-style) asking the user to allow tracking for a given key.
دالةGetResourceReturns a reference to a SResource using it's Resource name.
دالةLogEventLogs an analytics event to the server on white-label grids.
دالةLogLog a message to console.
خاصيةInventoryAllows access to the users inventory
خاصيةPersistenceStores information between user sessions, and for other users
خاصيةSceneAllows access to the current scene graph (objects and avatars in the scene, and other information)
خاصيةGrid–
خاصيةHostAccess information about the current scripting runtime host
خاصيةPhysicsCall physics-related commands, and variables, such as raycasting
خاصيةMathMath related functions (Sin, Cos, Tan, etc)
خاصيةStringMiscellaneous additional string functions (e.g. MD5Sum)
خاصيةInputInput device related functions (mouse position, keyboard state)
خاصيةCameraTake and control the users camera
خاصيةWebServicesCall remote web services to designated hosts (will not work with arbitrary domains, see page for details)
خاصيةNetworkSend data to other clients through the region server
خاصيةPostFX–
خاصيةAudioAnalyser–
خاصيةTween–
خاصيةUI–
خاصيةDialogues–
خاصيةShared–
خاصيةQuests–
خاصيةEconomy–
خاصيةGroups–
خاصيةActivity–
خاصيةRenderSettings–
خاصيةProfile–
خاصيةPhotos–
خاصيةVideos–
خاصيةMusicDirectory–
خاصيةJourney–
خاصيةGameTester–
خاصيةRuntimeTypeReturn current RuntimeType name.
خاصيةPlatformReturn current platform name.
خاصيةSessionIDReturn current SessionID.
خاصيةInEditorReturn true if in unity editor.
خاصيةVersionReturns the numeric build version of the viewer (for programmatic comparisons).
خاصيةFullVersionStringReturns the full build version display string tied to release notes (e.g., "2025.6f210").
خاصيةResources–
خاصيةTimeReturns time at the beginning of this frame.
خاصيةServerTimeReturns current server time.
خاصيةLocalTimeReturns current local time.
خاصيةLoginTimeReturns how long player has been logged in (in seconds).
خاصيةServerTimeUnixReturns the server time unix timestamp.
خاصيةLocalTimeUnixReturns the local time unix timestamp.
خاصيةDeltaTimeThe completion time in seconds since the last frame.
خاصيةPreviewServerReturn true if in preview server.
خاصيةComponentNameThe name of this component.

الدوال​

TypeName​

string TypeName(DynValue dv)

Return the type name of the value.

المعاملات

الاسمالنوعالقيمة الافتراضية
dvDynValue–

القيم المرجعة

string

مثال

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.

المعاملات

المعاملالنوعالوصف
keystringA unique identifier used to store and look up the user's tracking consent.

القيم المرجعة

bool

مثال

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.

المعاملات

المعاملالنوعالوصف
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.

القيم المرجعة

void

مثال

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.

المعاملات

المعاملالنوعالوصف
namestringName of the Resource as set in the Scripting Runtime Component (Resources section)

القيم المرجعة

SResource

مثال

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.

المعاملات

المعاملالنوعالوصف
eventNamestringThe name of the analytics event.
valuefloatA numeric value associated with the event.
positionSVectorA world position to associate with the event.

القيم المرجعة

void

مثال

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.

المعاملات

الاسمالنوعالقيمة الافتراضية
textDynValue–
logToFileboolfalse
textstring–

القيم المرجعة

void

مثال

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

الخصائص​

Inventoryللقراءة فقط​

SInventory Inventory {get; }

Allows access to the users inventory

مثال

Lua
inventory = Space.Inventory

Persistenceللقراءة فقط​

SPersistence Persistence {get; }

Stores information between user sessions, and for other users

مثال

``` persistence = Space.Persistence ```

Sceneللقراءة فقط​

SScene Scene {get; }

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

مثال

Lua
scene = Space.Scene

Gridللقراءة فقط​

SGrid Grid {get; }

مثال

Lua
grid = Space.Grid

Hostللقراءة فقط​

SHost Host {get; }

Access information about the current scripting runtime host

مثال

Lua
host = Space.Host

Physicsللقراءة فقط​

SPhysics Physics {get; }

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

مثال

Lua
physics = Space.Physics

Mathللقراءة فقط​

SMath Math {get; }

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

مثال

Lua
Space.Math.Ceil(4.0)

Stringللقراءة فقط​

SString String {get; }

Miscellaneous additional string functions (e.g. MD5Sum)

مثال

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

Inputللقراءة فقط​

SInput Input {get; }

Input device related functions (mouse position, keyboard state)

مثال

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

Cameraللقراءة فقط​

SCameraManager Camera {get; }

Take and control the users camera

مثال

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

WebServicesللقراءة فقط​

SWebService WebServices {get; }

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

مثال

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

Networkللقراءة فقط​

SNetwork Network {get; }

Send data to other clients through the region server

مثال

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

PostFXللقراءة فقط​

SPostFX PostFX {get; }

مثال

Lua
Space.PostFX

AudioAnalyserللقراءة فقط​

SAudioAnalyser AudioAnalyser {get; }

مثال

Lua
Space.AudioAnalyser

Tweenللقراءة فقط​

STween Tween {get; }

مثال

Lua
Space.Tween

UIللقراءة فقط​

SUI UI {get; }

مثال

Lua
ui = Space.UI

Dialoguesللقراءة فقط​

SDialogues Dialogues {get; }

مثال

Lua
dialogues = Space.Dialogues

Sharedللقراءة فقط​

SShared Shared {get; }

مثال

Lua
shared = Space.Shared

Questsللقراءة فقط​

SQuests Quests {get; }

مثال

Lua
quests = Space.Quests

Economyللقراءة فقط​

SEconomy Economy {get; }

مثال

Lua
economy = Space.Economy

Groupsللقراءة فقط​

SGroup Groups {get; }

مثال

Lua
groups = Space.Groups

Activityللقراءة فقط​

SActivity Activity {get; }

مثال

``` activity = Space.Activity ```

RenderSettingsللقراءة فقط​

SRenderSettings RenderSettings {get; }

مثال

Lua
renderSettings = Space.RenderSettings

Profileللقراءة فقط​

SProfile Profile {get; }

مثال

Lua
profile = Space.Profile

Photosللقراءة فقط​

SPhotos Photos {get; }

مثال

Lua
photos = Space.Photos

Videosللقراءة فقط​

SVideos Videos {get; }

مثال

Lua
videos = Space.Videos

MusicDirectoryللقراءة فقط​

SMusicDirectory MusicDirectory {get; }

مثال

Lua
musicDirectory = Space.MusicDirectory

Journeyللقراءة فقط​

SJourney Journey {get; }

مثال

Lua
journey = Space.Journey

GameTesterللقراءة فقط​

SGameTester GameTester {get; }

مثال

Lua
gameTester = Space.GameTester

RuntimeTypeللقراءة فقط​

string RuntimeType {get; }

Return current RuntimeType name.

مثال

Lua
runtimeType = Space.RuntimeType

Platformللقراءة فقط​

string Platform {get; }

Return current platform name.

مثال

Lua
platform = Space.Platform

SessionIDللقراءة فقط​

string SessionID {get; }

Return current SessionID.

مثال

Lua
sessionID = Space.SessionID

InEditorللقراءة فقط​

bool InEditor {get; }

Return true if in unity editor.

مثال

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)

Versionللقراءة فقط​

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.

مثال

Lua
viewerVersion = Space.Version

FullVersionStringللقراءة فقط​

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.

مثال

Lua
viewerVersionString = Space.FullVersionString

Resourcesللقراءة فقط​

SResource[] Resources {get; }

مثال

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

Timeللقراءة فقط​

float Time {get; }

Returns time at the beginning of this frame.

مثال

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)

ServerTimeللقراءة فقط​

string ServerTime {get; }

Returns current server time.

مثال

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)

LocalTimeللقراءة فقط​

string LocalTime {get; }

Returns current local time.

مثال

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)

LoginTimeللقراءة فقط​

float LoginTime {get; }

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

مثال

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)

ServerTimeUnixللقراءة فقط​

int ServerTimeUnix {get; }

Returns the server time unix timestamp.

مثال

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)

LocalTimeUnixللقراءة فقط​

int LocalTimeUnix {get; }

Returns the local time unix timestamp.

مثال

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)

DeltaTimeللقراءة فقط​

float DeltaTime {get; }

The completion time in seconds since the last frame.

مثال

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)

PreviewServerللقراءة فقط​

bool PreviewServer {get; }

Return true if in preview server.

مثال

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)

ComponentNameللقراءة فقط​

string ComponentName {get; }

The name of this component.

مثال

Lua
componentName = Space.ComponentName