wiki.sine.space | sinespace

Difference between revisions of "Scripting/SGrid"

From wiki.sine.space
Jump to: navigation, search
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/scene/sgrid")
 
Line 1: Line 1:
 
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/scene/sgrid
=Public Member Functions=
+
 
+
{{ScriptFunction|void|GetEnabledUserRegions|(Closure onComplete);|Gets an SUserRegions object which contains data about the user's regions (the information in the "Region List" window).|5=<pre></pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|void|GetRegionTexture|(SPublicRegion region, Closure onComplete);|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)|5=<pre>Space.Grid.GetRegionTexture(AnSPublicRegionObject,OnCompleteFunction)</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|void|GetRegionTexture|(string json, Closure onComplete);|Returns the Region Texture (the image seen while loading the region) as a resource. This function requires a string to identify which region. |5=<pre></pre>|6=<pre></pre>}}
+
 
+
{{ScriptFunction|void|GetOutfits|(Closure onComplete);|Gets the Grid's outfits as a table of SOutfit which contain Outfit data. |5=<pre></pre>|6=<pre></pre>}}
+
 
+
 
+
=Public Attributes=
+
{{ScriptFunction|int|OrientationRegion|{}|Returns the Region ID of the "Orientation Region".|5=<pre> orientationRegion = Space.Grid.OrientationRegion</pre>|6=<pre>--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)</pre>}}
+
 
+
=Properties=
+
 
+
{{ScriptFunction|bool|IsWhiteLabel|{ get;}|Returns true if this Grid is a white-label Grid. |5=<pre>isWhiteLabel = Space.Grid.IsWhiteLabel</pre>|6=<pre>--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)
+
</pre>}}
+
 
+
{{ScriptFunction|bool|PlayerIsAdmin|{ get;}|Returns true if this player's Grid role is Admin.(white-label grid only)|5=<pre>isAdmin = Space.Grid.PlayerIsAdmin</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|bool|PlayerIsModerator|{ get;}|Returns true if this player's Grid role is Moderator. (white-label grid only) |5=<pre>isModerator = Space.Grid.PlayerIsModerator</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|bool|PlayerIsDeveloper|{ get;}|Returns true if this player's Grid role is Developer.(white-label grid only)|5=<pre>isDeveloper = Space.Grid.PlayerIsDeveloper</pre>|6=<pre>--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)
+
</pre>}}
+
 
+
{{ScriptFunction|bool|PlayerIsTrusted|{ get;}|Returns true if this player's Grid role is Trusted.(white-label grid only)|5=<pre>isTrusted = Space.Grid.PlayerIsTrusted</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|string|Name|{ get;}|Returns the Grid's Name. (white-label grid only)|5=<pre>gridName = Space.Grid.Name</pre>|6=<pre>--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</pre>}}
+
 
+
{{ScriptFunction|string|SiteURL|{ get;}|Returns the Grid's Site URL. (white-label grid only)|5=<pre>siteUrl = Space.Grid.SiteURL</pre>|6=<pre>--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</pre>}}
+
 
+
{{ScriptFunction|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)|5=<pre>defaultRegion = Space.Grid.DefaultRegion</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|int[]|Avatars|{ get;}|Returns the IDs of all Avatars in the grid. (white-label grid only)|5=<pre>avatars = Space.Grid.Avatars</pre>|6=<pre>--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)
+
</pre>}}
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 07:22, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/scene/sgrid