# SScript

**الأعضاء** 51

|       |                                         |                                                                                                           |
| ----- | --------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| دالة  | [TypeName](#typename)                   | Return the type name of the value.                                                                        |
| دالة  | [TrackingAllowed](#trackingallowed)     | Returns true on white-label grids when the user has opted into tracking for the given key.                |
| دالة  | [TrackingRequest](#trackingrequest)     | Displays a consent prompt (EULA-style) asking the user to allow tracking for a given key.                 |
| دالة  | [GetResource](#getresource)             | Returns a reference to a SResource using it's Resource name.                                              |
| دالة  | [LogEvent](#logevent)                   | Logs an analytics event to the server on white-label grids.                                               |
| دالة  | [Log](#log)                             | Log a message to console.                                                                                 |
| خاصية | [Inventory](#inventory)                 | Allows access to the users inventory                                                                      |
| خاصية | [Persistence](#persistence)             | Stores information between user sessions, and for other users                                             |
| خاصية | [Scene](#scene)                         | Allows access to the current scene graph (objects and avatars in the scene, and other information)        |
| خاصية | [Grid](#grid)                           | –                                                                                                         |
| خاصية | [Host](#host)                           | Access information about the current scripting runtime host                                               |
| خاصية | [Physics](#physics)                     | Call physics-related commands, and variables, such as raycasting                                          |
| خاصية | [Math](#math)                           | Math related functions (Sin, Cos, Tan, etc)                                                               |
| خاصية | [String](#string)                       | Miscellaneous additional string functions (e.g. MD5Sum)                                                   |
| خاصية | [Input](#input)                         | Input device related functions (mouse position, keyboard state)                                           |
| خاصية | [Camera](#camera)                       | Take and control the users camera                                                                         |
| خاصية | [WebServices](#webservices)             | Call remote web services to designated hosts (will not work with arbitrary domains, see page for details) |
| خاصية | [Network](#network)                     | Send data to other clients through the region server                                                      |
| خاصية | [PostFX](#postfx)                       | –                                                                                                         |
| خاصية | [AudioAnalyser](#audioanalyser)         | –                                                                                                         |
| خاصية | [Tween](#tween)                         | –                                                                                                         |
| خاصية | [UI](#ui)                               | –                                                                                                         |
| خاصية | [Dialogues](#dialogues)                 | –                                                                                                         |
| خاصية | [Shared](#shared)                       | –                                                                                                         |
| خاصية | [Quests](#quests)                       | –                                                                                                         |
| خاصية | [Economy](#economy)                     | –                                                                                                         |
| خاصية | [Groups](#groups)                       | –                                                                                                         |
| خاصية | [Activity](#activity)                   | –                                                                                                         |
| خاصية | [RenderSettings](#rendersettings)       | –                                                                                                         |
| خاصية | [Profile](#profile)                     | –                                                                                                         |
| خاصية | [Photos](#photos)                       | –                                                                                                         |
| خاصية | [Videos](#videos)                       | –                                                                                                         |
| خاصية | [MusicDirectory](#musicdirectory)       | –                                                                                                         |
| خاصية | [Journey](#journey)                     | –                                                                                                         |
| خاصية | [GameTester](#gametester)               | –                                                                                                         |
| خاصية | [RuntimeType](#runtimetype)             | Return current RuntimeType name.                                                                          |
| خاصية | [Platform](#platform)                   | Return current platform name.                                                                             |
| خاصية | [SessionID](#sessionid)                 | Return current SessionID.                                                                                 |
| خاصية | [InEditor](#ineditor)                   | Return true if in unity editor.                                                                           |
| خاصية | [Version](#version)                     | Returns the numeric build version of the viewer (for programmatic comparisons).                           |
| خاصية | [FullVersionString](#fullversionstring) | Returns the full build version display string tied to release notes (e.g., "2025.6f210").                 |
| خاصية | [Resources](#resources)                 | –                                                                                                         |
| خاصية | [Time](#time)                           | Returns time at the beginning of this frame.                                                              |
| خاصية | [ServerTime](#servertime)               | Returns current server time.                                                                              |
| خاصية | [LocalTime](#localtime)                 | Returns current local time.                                                                               |
| خاصية | [LoginTime](#logintime)                 | Returns how long player has been logged in (in seconds).                                                  |
| خاصية | [ServerTimeUnix](#servertimeunix)       | Returns the server time unix timestamp.                                                                   |
| خاصية | [LocalTimeUnix](#localtimeunix)         | Returns the local time unix timestamp.                                                                    |
| خاصية | [DeltaTime](#deltatime)                 | The completion time in seconds since the last frame.                                                      |
| خاصية | [PreviewServer](#previewserver)         | Return true if in preview server.                                                                         |
| خاصية | [ComponentName](#componentname)         | The name of this component.                                                                               |

## الدوال

### TypeName

string TypeName(DynValue dv)

Return the type name of the value.

المعاملات

| الاسم | النوع    | القيمة الافتراضية |
| ----- | -------- | ----------------- |
| dv    | DynValue | –                 |

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

`string`

مثال

**Lua**

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

المعاملات

| المعامل | النوع  | الوصف                                                                      |
| ------- | ------ | -------------------------------------------------------------------------- |
| key     | string | A unique identifier used to store and look up the user's tracking consent. |

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

`bool`

مثال

**Lua**

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

المعاملات

| المعامل       | النوع   | الوصف                                                                                |
| ------------- | ------- | ------------------------------------------------------------------------------------ |
| 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    | If `true`, show the prompt even if a stored decision exists. Defaults to `false`.    |

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

`void`

مثال

**Lua**

```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](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md) GetResource(string name)

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

المعاملات

| المعامل | النوع  | الوصف                                                                              |
| ------- | ------ | ---------------------------------------------------------------------------------- |
| name    | string | Name of the Resource as set in the Scripting Runtime Component (Resources section) |

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

`SResource`

مثال

**Lua**

```lua
aResource = Space.GetResource("ResourceName")

```

### LogEvent

void LogEvent(string eventName, float value, [SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) position)

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

المعاملات

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

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

`void`

مثال

**Lua**

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

المعاملات

| الاسم     | النوع    | القيمة الافتراضية |
| --------- | -------- | ----------------- |
| text      | DynValue | –                 |
| logToFile | bool     | false             |
| text      | string   | –                 |

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

`void`

مثال

**Lua**

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

```

## الخصائص

### Inventory

[SInventory](/docs/ar/scripting/client-scripting-api-reference/player/sinventory.md) Inventory {get; }

Allows access to the users inventory

مثال

**Lua**

```lua
inventory  = Space.Inventory

```

### Persistence

[SPersistence](/docs/ar/scripting/client-scripting-api-reference/region/spersistence.md) Persistence {get; }

Stores information between user sessions, and for other users

مثال

\`\`\` persistence = Space.Persistence \`\`\`

### Scene

[SScene](/docs/ar/scripting/client-scripting-api-reference/region/sscene.md) Scene {get; }

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

مثال

**Lua**

```lua
scene = Space.Scene

```

### Grid

[SGrid](/docs/ar/scripting/client-scripting-api-reference/region/sgrid.md) Grid {get; }

مثال

**Lua**

```lua
grid = Space.Grid

```

### Host

[SHost](/docs/ar/scripting/client-scripting-api-reference/region/shost.md) Host {get; }

Access information about the current scripting runtime host

مثال

**Lua**

```lua
host = Space.Host

```

### Physics

[SPhysics](/docs/ar/scripting/client-scripting-api-reference/region/sphysics.md) Physics {get; }

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

مثال

**Lua**

```lua
physics = Space.Physics

```

### Math

[SMath](/docs/ar/scripting/client-scripting-api-reference/types/smath.md) Math {get; }

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

مثال

**Lua**

```lua
Space.Math.Ceil(4.0)

```

### String

[SString](/docs/ar/scripting/client-scripting-api-reference/types/sstring.md) String {get; }

Miscellaneous additional string functions (e.g. MD5Sum)

مثال

**Lua**

```lua
Space.String.GetBytes("some data")

```

### Input

[SInput](/docs/ar/scripting/client-scripting-api-reference/client/sinput.md) Input {get; }

Input device related functions (mouse position, keyboard state)

مثال

**Lua**

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

```

### Camera

[SCameraManager](/docs/ar/scripting/client-scripting-api-reference/region/scameramanager.md) Camera {get; }

Take and control the users camera

مثال

**Lua**

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

```

### WebServices

[SWebService](/docs/ar/scripting/client-scripting-api-reference/network/swebservice.md) WebServices {get; }

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

مثال

**Lua**

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

```

### Network

[SNetwork](/docs/ar/scripting/client-scripting-api-reference/network/snetwork.md) Network {get; }

Send data to other clients through the region server

مثال

**Lua**

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

```

### PostFX

[SPostFX](/docs/ar/scripting/client-scripting-api-reference/region/spostfx.md) PostFX {get; }

مثال

**Lua**

```lua
Space.PostFX

```

### AudioAnalyser

SAudioAnalyser AudioAnalyser {get; }

مثال

**Lua**

```lua
Space.AudioAnalyser

```

### Tween

STween Tween {get; }

مثال

**Lua**

```lua
Space.Tween

```

### UI

[SUI](/docs/ar/scripting/client-scripting-api-reference/client/sui.md) UI {get; }

مثال

**Lua**

```lua
ui = Space.UI

```

### Dialogues

[SDialogues](/docs/ar/scripting/client-scripting-api-reference/client/sdialogues.md) Dialogues {get; }

مثال

**Lua**

```lua
dialogues = Space.Dialogues

```

### Shared

[SShared](/docs/ar/scripting/client-scripting-api-reference/client/sshared.md) Shared {get; }

مثال

**Lua**

```lua
shared = Space.Shared

```

### Quests

[SQuests](/docs/ar/scripting/client-scripting-api-reference/player/squests.md) Quests {get; }

مثال

**Lua**

```lua
quests = Space.Quests

```

### Economy

[SEconomy](/docs/ar/scripting/client-scripting-api-reference/player/seconomy.md) Economy {get; }

مثال

**Lua**

```lua
economy = Space.Economy

```

### Groups

[SGroup](/docs/ar/scripting/client-scripting-api-reference/player/sgroup.md) Groups {get; }

مثال

**Lua**

```lua
groups = Space.Groups

```

### Activity

SActivity Activity {get; }

مثال

\`\`\` activity = Space.Activity \`\`\`

### RenderSettings

[SRenderSettings](/docs/ar/scripting/client-scripting-api-reference/region/srendersettings.md) RenderSettings {get; }

مثال

**Lua**

```lua
renderSettings = Space.RenderSettings

```

### Profile

[SProfile](/docs/ar/scripting/client-scripting-api-reference/player/sprofile.md) Profile {get; }

مثال

**Lua**

```lua
profile = Space.Profile

```

### Photos

[SPhotos](/docs/ar/scripting/client-scripting-api-reference/network/sphotos.md) Photos {get; }

مثال

**Lua**

```lua
photos = Space.Photos

```

### Videos

[SVideos](/docs/ar/scripting/client-scripting-api-reference/network/svideos.md) Videos {get; }

مثال

**Lua**

```lua
videos = Space.Videos

```

### MusicDirectory

SMusicDirectory MusicDirectory {get; }

مثال

**Lua**

```lua
musicDirectory = Space.MusicDirectory

```

### Journey

SJourney Journey {get; }

مثال

**Lua**

```lua
journey = Space.Journey

```

### GameTester

SGameTester GameTester {get; }

مثال

**Lua**

```lua
gameTester = Space.GameTester

```

### RuntimeType

string RuntimeType {get; }

Return current RuntimeType name.

مثال

**Lua**

```lua
runtimeType = Space.RuntimeType

```

### Platform

string Platform {get; }

Return current platform name.

مثال

**Lua**

```lua
platform = Space.Platform

```

### SessionID

string SessionID {get; }

Return current SessionID.

مثال

**Lua**

```lua
sessionID = Space.SessionID

```

### InEditor

bool InEditor {get; }

Return true if in unity editor.

مثال

**Lua**

```lua
isInEditor = Space.InEditor

```

**Lua**

```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**

```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**

```lua
viewerVersionString = Space.FullVersionString

```

### Resources

[SResource](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md)\[] Resources {get; }

مثال

**Lua**

```lua
tableOfResources = Space.Resources

```

**Lua**

```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**

```lua
floatTime = Space.Time

```

**Lua**

```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**

```lua
serverTime = Space.ServerTime

```

**Lua**

```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**

```lua
localTime = Space.LocalTime

```

**Lua**

```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**

```lua
loginTime = Space.LoginTime

```

**Lua**

```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**

```lua
serverTimeUnix = Space.ServerTimeUnix

```

**Lua**

```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**

```lua
localTimeUnix = Space.LocalTimeUnix

```

**Lua**

```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**

```lua
deltaTime = Space.DeltaTime

```

**Lua**

```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**

```lua
isInPreview = Space.PreviewServer

```

**Lua**

```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**

```lua
componentName = Space.ComponentName

```
