SGrid
| 函数 | GetEnabledUserRegions | Calling this function will asynchronously get and return information about this player's regions as SUserRegions. (This is the same information in the "Region List" window). |
| 函数 | GetRegionTexture | Returns the Region Texture (the image seen while loading the region) as a resource. |
| 函数 | GetOutfits | Calling this function will asynchronously get and return information about this player's outfits as a List of SOutfit. |
| 属性 | IsWhiteLabel | Returns true if this Grid is a white-label Grid. |
| 属性 | PlayerIsAdmin | Returns true if this player's Grid role is Admin.(white-label grid only) |
| 属性 | PlayerIsModerator | Returns true if this player's Grid role is Moderator. (white-label grid only) |
| 属性 | PlayerIsDeveloper | Returns true if this player's Grid role is Developer.(white-label grid only) |
| 属性 | PlayerIsTrusted | Returns true if this player's Grid role is Trusted.(white-label grid only) |
| 属性 | ThemeColor1 | The viewer's Theme Color 1. |
| 属性 | ThemeColor2 | The viewer's Theme Color 2. |
| 属性 | ThemeColor3 | The viewer's Theme Color 3. |
| 属性 | ThemeColor4 | The viewer's Theme Color 4. |
| 属性 | TextColor1 | The viewer's Text Color 1. |
| 属性 | TextColor2 | The viewer's Text Color 2. |
| 属性 | Name | Returns the Grid's Name. (white-label grid only) |
| 属性 | SiteURL | Returns the Grid's Site URL. (white-label grid only) |
| 属性 | DefaultRegion | Returns the Region ID of the Default Region. |
| 属性 | Avatars | Returns the IDs of all Avatars in the grid. (white-label grid only) |
| 属性 | OrientationRegion | Returns the Region ID of the "Orientation Region". |
函数
GetEnabledUserRegions
Calling this function will asynchronously get and return information about this player's regions as SUserRegions. (This is the same information in the "Region List" window).
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| onComplete | Closure (Callback) | onComplete is a function that will be called on completion with SUserRegions as a parameter. |
返回值
void
示例
function GetUserRegionsComplete(SUserRegions)
--
end
Space.Grid.GetEnabledUserRegions(GetUserRegionsComplete)
--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)
GetRegionTexture
Returns the Region Texture (the image seen while loading the region) as a resource. This function requires an SPublicRegion object to identify which region. (white-label grids only)
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| region | SPublicRegion | – |
| onComplete | Closure | – |
| json | string | – |
返回值
void
示例
Space.Grid.GetRegionTexture(AnSPublicRegionObject,OnCompleteFunction)
--see below example
--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)
GetOutfits
Calling this function will asynchronously get and return information about this player's outfits as a List of SOutfit.
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| onComplete | Closure (Callback) | onComplete is a function that will be called on completion with a List of SOutfit as a parameter. |
返回值
void
示例
function OnGetOutfitsComplete(TableSOutfits)
--
end
Space.Grid.GetOutfits(OnGetOutfitsComplete)
属性
IsWhiteLabel只读
Returns true if this Grid is a white-label Grid.
示例
isWhiteLabel = Space.Grid.IsWhiteLabel
--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)
PlayerIsAdmin只读
Returns true if this player's Grid role is Admin.(white-label grid only)
示例
isAdmin = Space.Grid.PlayerIsAdmin
--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)
PlayerIsModerator只读
Returns true if this player's Grid role is Moderator. (white-label grid only)
示例
isModerator = Space.Grid.PlayerIsModerator
--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)
PlayerIsDeveloper只读
Returns true if this player's Grid role is Developer.(white-label grid only)
示例
isDeveloper = Space.Grid.PlayerIsDeveloper
--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)
PlayerIsTrusted只读
Returns true if this player's Grid role is Trusted.(white-label grid only)
示例
isTrusted = Space.Grid.PlayerIsTrusted
--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)
ThemeColor1只读
The viewer's Theme Color 1.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
示例
themeColor1 = Space.Grid.ThemeColor1
ThemeColor2只读
The viewer's Theme Color 2.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
示例
themeColor2 = Space.Grid.ThemeColor2
ThemeColor3只读
The viewer's Theme Color 3.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
示例
themeColor3 = Space.Grid.ThemeColor3
ThemeColor4只读
The viewer's Theme Color 4.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
示例
themeColor4 = Space.Grid.ThemeColor4
TextColor1只读
The viewer's Text Color 1.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
示例
textColor1 = Space.Grid.TextColor1
TextColor2只读
The viewer's Text Color 2.
The viewer's theme consist of 4 Theme Colors and 2 Text Colors.
示例
textColor2 = Space.Grid.TextColor2
Name只读
Returns the Grid's Name. (white-label grid only)
示例
gridName = Space.Grid.Name
--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
SiteURL只读
Returns the Grid's Site URL. (white-label grid only)
示例
siteUrl = Space.Grid.SiteURL
--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
DefaultRegion只读
Returns the Region ID of the Default Region. The Default Region is set in the grid's Dashboard. (white-label grid only)
示例
defaultRegion = Space.Grid.DefaultRegion
--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)
Avatars只读
Returns the IDs of all Avatars in the grid. (white-label grid only)
示例
avatars = Space.Grid.Avatars
--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)
OrientationRegion只读
Returns the Region ID of the "Orientation Region".
示例
orientationRegion = Space.Grid.OrientationRegion
--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)



