# SGrid

## Index

### Functions Index

| Function Name                                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| void [**GetEnabledUserRegions** ](#getenableduserregions)(Closure onComplete)                                                                                                                                                        |
| <p>void <a href="#getregiontexture"><strong>GetRegionTexture</strong> </a>(SPublicRegion region, Closure onComplete)<br>void <a href="#getregiontexture"><strong>GetRegionTexture</strong> </a>(string json, Closure onComplete)</p> |
| void [**GetOutfits** ](#getoutfits)(Closure onComplete)                                                                                                                                                                              |

### Properties Index

| Property Name                                          |
| ------------------------------------------------------ |
| bool [**IsWhiteLabel** ](#iswhitelabel)`get`           |
| bool [**PlayerIsAdmin** ](#playerisadmin)`get`         |
| bool [**PlayerIsModerator** ](#playerismoderator)`get` |
| bool [**PlayerIsDeveloper** ](#playerisdeveloper)`get` |
| bool [**PlayerIsTrusted** ](#playeristrusted)`get`     |
| SColor [**ThemeColor1** ](#themecolor1)`get`           |
| SColor [**ThemeColor2** ](#themecolor2)`get`           |
| SColor [**ThemeColor3** ](#themecolor3)`get`           |
| SColor [**ThemeColor4** ](#themecolor4)`get`           |
| SColor [**TextColor1** ](#textcolor1)`get`             |
| SColor [**TextColor2** ](#textcolor2)`get`             |
| string [**Name**](#name) `get`                         |
| string [**SiteURL** ](#siteurl)`get`                   |
| int [**DefaultRegion** ](#defaultregion)`get`          |
| int\[] [**Avatars** ](#avatars)`get`                   |
| int [**OrientationRegion** ](#orientationregion)`get`  |

## Functions

### GetEnabledUserRegions

void **GetEnabledUserRegions** (Closure onComplete)

*Calling this function will asynchronously get and return information about this player's regions as* [*SUserRegions.* ](https://docs.sine.space/scripting/client-scripting-api-reference/types/suserregions)*(This is the same information in the "Region List" window).*

| Parameter  | Type               | Description                                                                                                                                                          |
| ---------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| onComplete | Closure (Callback) | <p>onComplete is a function that will be called on completion with <a href="../types/suserregions">SUserRegions </a>as a parameter.<br>onComplete(SUserRegions) </p> |
|            |                    |                                                                                                                                                                      |

{% tabs %}
{% tab title="Lua" %}

```lua
function GetUserRegionsComplete(SUserRegions)
--
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### GetRegionTexture

void **GetRegionTexture** ([SPublicRegion ](https://docs.sine.space/scripting/client-scripting-api-reference/types/spublicregion)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* [*SPublicRegion*](https://docs.sine.space/scripting/client-scripting-api-reference/types/spublicregion) *object to identify which region. (white-label grids only)*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Grid.GetRegionTexture(AnSPublicRegionObject,OnCompleteFunction)
--see below example
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### GetOutfits

void **GetOutfits** (Closure onComplete)

*Calling this function will asynchronously get and return information about this player's outfits as a List of* [*SOutfit*](https://docs.sine.space/scripting/client-scripting-api-reference/types/soutfit)*.*

| Parameter  | Type               | Description                                                                                                                                                                         |
| ---------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| onComplete | Closure (Callback) | onComplete is a function that will be called on completion with a List of [SOutfit](https://docs.sine.space/scripting/client-scripting-api-reference/types/soutfit) as a parameter. |

{% tabs %}
{% tab title="Lua" %}

```lua
function OnGetOutfitsComplete(TableSOutfits)
--
end
Space.Grid.GetOutfits(OnGetOutfitsComplete)
```

{% endtab %}
{% endtabs %}

## Properties

### IsWhiteLabel

bool **IsWhiteLabel** `get`

*Returns true if this Grid is a white-label Grid.*

{% tabs %}
{% tab title="Lua" %}

```lua
isWhiteLabel = Space.Grid.IsWhiteLabel
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### PlayerIsAdmin

bool **PlayerIsAdmin** `get`

*Returns true if this player's Grid role is Admin.(white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
isAdmin = Space.Grid.PlayerIsAdmin
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### PlayerIsModerator

bool **PlayerIsModerator** `get`

*Returns true if this player's Grid role is Moderator. (white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
isModerator = Space.Grid.PlayerIsModerator
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### PlayerIsDeveloper

bool **PlayerIsDeveloper** `get`

*Returns true if this player's Grid role is Developer.(white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
isDeveloper = Space.Grid.PlayerIsDeveloper
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### PlayerIsTrusted

bool **PlayerIsTrusted** `get`

*Returns true if this player's Grid role is Trusted.(white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
isTrusted = Space.Grid.PlayerIsTrusted
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### ThemeColor1

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **ThemeColor1** `get`

*The viewer's **Theme Color 1**.*

*The viewer's theme consist of 4 Theme Colors and 2 Text Colors.*&#x20;

{% tabs %}
{% tab title="Lua" %}

```lua
themeColor1 = Space.Grid.ThemeColor1
```

{% endtab %}
{% endtabs %}

### ThemeColor2

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **ThemeColor2** `get`

*The viewer's **Theme Color 2**.*

*The viewer's theme consist of 4 Theme Colors and 2 Text Colors.*&#x20;

{% tabs %}
{% tab title="Lua" %}

```lua
themeColor2 = Space.Grid.ThemeColor2
```

{% endtab %}
{% endtabs %}

### ThemeColor3

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **ThemeColor3** `get`

*The viewer's **Theme Color 3**.*

*The viewer's theme consist of 4 Theme Colors and 2 Text Colors.*&#x20;

{% tabs %}
{% tab title="Lua" %}

```lua
themeColor3 = Space.Grid.ThemeColor3
```

{% endtab %}
{% endtabs %}

### ThemeColor4

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **ThemeColor4** `get`

*The viewer's **Theme Color 4**.*

*The viewer's theme consist of 4 Theme Colors and 2 Text Colors.*&#x20;

{% tabs %}
{% tab title="Lua" %}

```lua
themeColor4 = Space.Grid.ThemeColor4
```

{% endtab %}
{% endtabs %}

### TextColor1

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **TextColor1** `get`

*The viewer's **Text Color 1**.*

*The viewer's theme consist of 4 Theme Colors and 2 Text Colors.*&#x20;

{% tabs %}
{% tab title="Lua" %}

```lua
textColor1 = Space.Grid.TextColor1
```

{% endtab %}
{% endtabs %}

### TextColor2

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **TextColor2** `get`

*The viewer's **Text Color 2**.*

*The viewer's theme consist of 4 Theme Colors and 2 Text Colors.*&#x20;

{% tabs %}
{% tab title="Lua" %}

```lua
textColor2 = Space.Grid.TextColor2
```

{% endtab %}
{% endtabs %}

### Name

string **Name** `get`

*Returns the Grid's Name. (white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
gridName = Space.Grid.Name
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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(OnClickFunction
```

{% endtab %}
{% endtabs %}

### SiteURL

string **SiteURL** `get`

*Returns the Grid's Site URL. (white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
siteUrl = Space.Grid.SiteURL
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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(OnClickFunction
```

{% endtab %}
{% endtabs %}

### DefaultRegion

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

{% tabs %}
{% tab title="Lua" %}

```lua
defaultRegion = Space.Grid.DefaultRegion
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### Avatars

int\[] **Avatars** `get`

*Returns the IDs of all Avatars in the grid. (white-label grid only)*

{% tabs %}
{% tab title="Lua" %}

```lua
avatars = Space.Grid.Avatars
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}

### OrientationRegion

int **OrientationRegion** `get`

*Returns the Region ID of the "Orientation Region".*

{% tabs %}
{% tab title="Lua" %}

```lua
 orientationRegion = Space.Grid.OrientationRegion
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--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)
```

{% endtab %}
{% endtabs %}
