wiki.sine.space | sinespace

Difference between revisions of "Scripting/SScene"

From wiki.sine.space
Jump to: navigation, search
(Added simple example to SScene.Find)
(Added simple examples to SScene .PlayerAvatar .Avatars .Objects .CreateGameObject .Name .Url .Owner .PlayerIsOwner)
Line 18: Line 18:
 
--This returns the GameObject named Hand,
 
--This returns the GameObject named Hand,
 
--which is a child of Arm > Monster. </pre>}}
 
--which is a child of Arm > Monster. </pre>}}
{{ScriptFunction|SAvatar|PlayerAvatar|{ get; }|Returns the current player avatar. If this script is calling this upon initialisation, the Player may not exist yet, and you will want to wait a few frames until the avatar is present before continuing.}}
+
{{ScriptFunction|SAvatar|PlayerAvatar|{ get; }|Returns the current player avatar. If this script is calling this upon initialisation, the Player may not exist yet, and you will want to wait a few frames until the avatar is present before continuing.  
{{ScriptFunction|SAvatar|Avatars[]|{ get; }|Returns a list of Avatars in the scene}}
+
<pre> CurrentPlayer = Space.Scene.PlayerAvatar </pre>}}
{{ScriptFunction|SGameObject|Objects[]|{ get; }|Returns a list of Objects in the scene. '''IMPORTANT: This function is slow, you should cache the result and avoid calling this every frame.'''}}
+
{{ScriptFunction|SAvatar|Avatars[]|{ get; }|Returns a list of Avatars in the scene|5=
{{ScriptFunction|SGameObject|CreateGameObject|(string name);|Creates a new empty game object with the name 'Name' and returns a reference}}
+
<pre>avatars = Space.Scene.Avatars  </pre>}}
 +
{{ScriptFunction|SGameObject|Objects[]|{ get; }|Returns a list of Objects in the scene. '''IMPORTANT: This function is slow, you should cache the result and avoid calling this every frame.'''|5=
 +
<pre> objects = Space.Scene.Objects </pre>}}
 +
{{ScriptFunction|SGameObject|CreateGameObject|(string name);|Creates a new empty game object with the name 'Name' and returns a reference|5=
 +
<pre>newObject = Space.Scene.CreateGameObject("potato")</pre>}}
 
{{ScriptFunction|SGameObject|CreateGameObject|([[Scripting/SResource|SResource]] resource);|Creates a game object from the specified resource}}
 
{{ScriptFunction|SGameObject|CreateGameObject|([[Scripting/SResource|SResource]] resource);|Creates a game object from the specified resource}}
{{ScriptFunction|string|Name|{ get; }|Returns the name of the current region}}
+
{{ScriptFunction|string|Name|{ get; }|Returns the name of the current region|5=
{{ScriptFunction|string|Url|{ get; }|Returns the URL of the current region}}
+
<pre>RegionName = Space.Scene.Name </pre>}}
{{ScriptFunction|long|Owner|{ get; }|Returns the avatar ID of the regions owner}}
+
{{ScriptFunction|string|Url|{ get; }|Returns the URL of the current region|5=
{{ScriptFunction|bool|PlayerIsOwner|{ get; }|Returns whether the current player is the owner of the region}}
+
<pre>RegionUrl = Space.Scene.Url </pre>}}
 +
{{ScriptFunction|long|Owner|{ get; }|Returns the avatar ID of the regions owner|5=
 +
<pre>RegionOwner = Space.Scene.Owner</pre>}}
 +
{{ScriptFunction|bool|PlayerIsOwner|{ get; }|Returns whether the current player is the owner of the region|5=
 +
<pre>isOwner = Space.Scene.PlayerIsOwner </pre>}}
 
{{ScriptFunction|void|OnPlayerJoin|(Action<[[Scripting/SAvatar|SAvatar]]> callback)|Event which fires whenever a player joins the region}}
 
{{ScriptFunction|void|OnPlayerJoin|(Action<[[Scripting/SAvatar|SAvatar]]> callback)|Event which fires whenever a player joins the region}}
 
{{ScriptFunction|void|OnPlayerLeave|(Action<long> callback)|Event which fires whenever a player leaves the region}}
 
{{ScriptFunction|void|OnPlayerLeave|(Action<long> callback)|Event which fires whenever a player leaves the region}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 09:35, 11 December 2020

The SScene class represents the region the user is currently in.

Members

Find

SGameObject Find (string name);

Finds a single Game Object matching 'Name' and returns it. Can use '/' characters to designate a path (e.g. 'Parent/Child' returns Child with 'Parent')

5e
 hand = Space.Scene.Find("Hand");
--This returns the GameObject named Hand.

hand = Space.Scene.Find("/Hand");
--This returns the GameObject named Hand.
--Hand must not have a parent in the Hierarchy view.

hand = Space.Scene.Find("/Monster/Arm/Hand");
--This returns the GameObject named Hand,
--which is a child of Arm > Monster.
--Monster must not have a parent in the Hierarchy view.

hand = Space.Scene.Find("Monster/Arm/Hand");
--This returns the GameObject named Hand,
--which is a child of Arm > Monster. 


PlayerAvatar

SAvatar PlayerAvatar { get; }

Returns the current player avatar. If this script is calling this upon initialisation, the Player may not exist yet, and you will want to wait a few frames until the avatar is present before continuing.

 CurrentPlayer = Space.Scene.PlayerAvatar 
No example provided yet


Avatars[]

SAvatar Avatars[] { get; }

Returns a list of Avatars in the scene

avatars = Space.Scene.Avatars  


Objects[]

SGameObject Objects[] { get; }

Returns a list of Objects in the scene. IMPORTANT: This function is slow, you should cache the result and avoid calling this every frame.

 objects = Space.Scene.Objects 


CreateGameObject

SGameObject CreateGameObject (string name);

Creates a new empty game object with the name 'Name' and returns a reference

newObject = Space.Scene.CreateGameObject("potato")


CreateGameObject

SGameObject CreateGameObject (SResource resource);

Creates a game object from the specified resource

No example provided yet


Name

string Name { get; }

Returns the name of the current region

RegionName = Space.Scene.Name 


Url

string Url { get; }

Returns the URL of the current region

RegionUrl = Space.Scene.Url 


Owner

long Owner { get; }

Returns the avatar ID of the regions owner

RegionOwner = Space.Scene.Owner


PlayerIsOwner

bool PlayerIsOwner { get; }

Returns whether the current player is the owner of the region

isOwner = Space.Scene.PlayerIsOwner 


OnPlayerJoin

void OnPlayerJoin (Action<SAvatar> callback)

Event which fires whenever a player joins the region

No example provided yet


OnPlayerLeave

void OnPlayerLeave (Action<long> callback)

Event which fires whenever a player leaves the region

No example provided yet