All pages
Powered by GitBook
1 of 8

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Region

SAvatar

Index

Properties Index

Property

Properties

ID

int ID get

Avatar's ID

Position

Vector3 Position get

Avatar's position

Velocity

Vector3 Velocity get

Avatar's Velocity

Rotation

Quaternion Rotation get

Avatar's Rotation

Username

string Username get

Avatar's Username

Title

string Title get

Avatar's Title

SParcelManager

Index

Functions Index

Function

Properties Index

Property

Functions

GetParcel

SParcel GetParcel (string id)

Function Description

Parameter
Type
Description

Properties

AllParcels

Table AllParcels get

Property Description

int ID get

Vector3 Position get

Vector3 Velocity get

Quaternion Rotation get

string Username get

string Title get

ID = Space.Scene.Avatars[1].ID
--server script that prints a list of IDs of players online whenever someone joins
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars

  for num =1 , numOfAvatars, 1 do
    Space.Log(Space.Scene.Avatars[num].ID)
  end
end

SParcel GetParcel (string id)

Table AllParcels get

example 1
example 2
ID = Space.Scene.Avatars[1].Position
--server script that prints a list of Positions of players online whenever someone joins
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars

  for num =1 , numOfAvatars, 1 do
    Space.Log(Space.Scene.Avatars[num].Position)
  end
end
ID = Space.Scene.Avatars[1].Velocity
--server script that prints a list of Velocitys of players online whenever someone joins
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars

  for num =1 , numOfAvatars, 1 do
    Space.Log(Space.Scene.Avatars[num].Velocity)
  end
end
ID = Space.Scene.Avatars[1].Quaternion 
--server script that prints a list of Rotations of players online whenever someone joins
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars

  for num =1 , numOfAvatars, 1 do
    Space.Log(Space.Scene.Avatars[num].Rotation)
  end
end
ID = Space.Scene.Avatars[1].Username
--server script that prints a list of Usernames of players online whenever someone joins
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars

  for num =1 , numOfAvatars, 1 do
    Space.Log(Space.Scene.Avatars[num].Username)
  end
end
ID = Space.Scene.Avatars[1].Title
--server script that prints a list of Titles of players online whenever someone joins
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars

  for num =1 , numOfAvatars, 1 do
    Space.Log(Space.Scene.Avatars[num].Title)
  end
end
example 1
example 2

SParcel

Index

Properties Index

Property

Properties

ID

string ID get

Property Description

Name

string Name get

Property Description

DescriptionName

string DescriptionName get

Property Description

ForSale

bool ForSale get

Property Description

GoldSalePrice

int GoldSalePrice get

Property Description

SilverSalePrice

int SilverSalePrice get

Property Description

GoldRentalPrice

int GoldRentalPrice get

Property Description

SilverRentalPrice

int SilverRentalPrice get

Property Description

SObject

Index

Functions Index

Function

Properties Index

Property

Functions

GetProperty

string GetProperty (string property)

Function Description

Parameter
Type
Description

SetProperty

void SetProperty (string property, string value)

Function Description

Parameter
Type
Description

Properties

Cell

SCell Cell get

Property Description

ID

string ID get

Property Description

Floor

string Floor get

Property Description

Position

Vector3 Position get set

Property Description

Rotation

Quaternion Rotation get set

Property Description

Scale

Vector3 Scale get set

Property Description

Player

int Player get

Property Description

InventoryID

int InventoryID get

Property Description

ItemID

int ItemID get

Property Description

Bounds

Bounds Bounds get

Property Description

SCell

Index

Functions Index

Function

string ID get

string Name get

string DescriptionName get

bool ForSale get

int GoldSalePrice get

int SilverSalePrice get

int GoldRentalPrice get

int SilverRentalPrice get

example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2

SObject (string id)

Properties Index

Property

Table get

Functions

GetObject

SObject GetObject (string id)

Function Description

Parameter
Type
Description

example 1
example 2

Properties

Objects

Table Objects get

Property Description

string GetProperty (string property)

void SetProperty (string property, string value)

SCell Cell get

string ID get

string Floor get

Vector3 Position get set

Quaternion Rotation get set

Vector3 Scale get set

int Player get

int InventoryID get

int ItemID get

Bounds get

example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
example 1
example 2
Bounds
GetObject
Objects

SScene

Index

Properties Index

Property

Properties

ConnectedAvatars

int ConnectedAvatars get

Returns the number of Avatars connected to the region.

Avatars

Table Avatars get

Returns a table of SAvatar objects currently in the region

Cells

Table Cells get

Returns a table of SCell objects. (Not all cells are available at all times, a client on this server must be within 384m of a cell in order for it to exist.)

Parcels

Parcels get

Access to the SParcelManager class.

int ConnectedAvatars get

Table Avatars get

Table Cells get

SParcelManager Parcels get

SParcelManager
numOfAvatars = Space.Scene.ConnectedAvatars
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars
  Space.Log("Avatar with ID " .. id .. "has joined")
  Space.Log("Number of avatars connected: " .. numOfAvatars)
end
currentAvatars = Space.Scene.Avatars
cellsTable = Space.Scene.Cells
Space.Scene.Parcels

SRegionScript

Index

Functions Index

Function

Properties Index

Property

Events Index

Event

Functions

Log

void Log (string message)

Log a message to console. (only works on preview grid)

Parameter
Type
Description

SubscribeToNetwork

void SubscribeToNetwork (string key)

Subscribe to network messages on "key".

Parameter
Type
Description

UnsubscribeFromNetwork

void UnsubscribeFromNetwork (string key)

Unsubscribe from network messages on "key".

Parameter
Type
Description

SendMessageToAllClientScripts

void SendMessageToAllClientScripts (string messageName, Table message)

Sends a network message to all client scripts.

Parameter
Type
Description

SendMessageToClientScripts

void SendMessageToClientScripts (ulong playerID, string messageName, Table message)

Sends a network message to a client script belonging to a specific player

Parameter
Type
Description

StartCoroutine

void StartCoroutine (DynValue coroutine, DynValue parameter=default(DynValue)) void StartCoroutine (string name, DynValue parameter=default(DynValue))

Runs the given function as a coroutine. A parameter is optional.

Parameter
Type
Description

Properties

ScriptID

string ScriptID get

Returns a unique identifier of this script runtime. (can be found in "/list_scripts" window on preview.)

InstanceID

uint InstanceID get

Returns a unique identifier for the instance of the region. Useful in the case of multiple shards/instances being used. InstanceID does not necessarily equal to the RegionID, even if there's only one instance running.

RegionID

ulong RegionID get

Returns a unique identifier for the region. (Same ID seen in curator)

Scene

Scene get

Access to the SScene class methods and properties.

Database

Database get

Access to the SDatabase class methods and properties.

Math

Math get

Access to the SMath class methods and properties.

Shared

Shared get

Access to the SShared class methods and properties.

WebServices

WebServices get

Access to the SWebservice class methods and properties.

RuntimeType

string RuntimeType get

Returns "Server" if this script is a Server script

InEditor

bool InEditor get

Returns true if in Editor. (this will return false on server scripts)

TimeSinceAwake

float TimeSinceAwake get

Time, in seconds, since this script runtime has been awake.

DateTimeUTC

string DateTimeUTC get

Returns a string of the current Date/Time in UTC

LocalTimeUnix

int LocalTimeUnix get

Returns the current Unix time (in seconds) (same as ServerTimeUnix)

ServerTimeUnix

int ServerTimeUnix get

Returns the current Unix time (in seconds) (same as LocalTimeUnix)

Events

OnAvatarJoin

Action< int > OnAvatarJoin

An event function which will be called whenever an Avatar joins and will also contain the Avatar's ID as a parameter.

OnAvatarLeave

Action< int > OnAvatarLeave

An event function which will be called whenever an Avatar leaves and will also contain the Avatar's ID as a parameter.

OnScriptServerMessage

Action< string, Table > OnScriptServerMessage

An event function which will be called whenever the server script receives a Network Message, and will contain the network message key String and message Table as a parameter.

int get

int get

void Log (string message)

void SubscribeToNetwork (string key)

void UnsubscribeFromNetwork (string key)

void SendMessageToAllClientScripts (string messageName, Table message)

void SendMessageToClientScripts (ulong playerID, string messageName, Table message)

void StartCoroutine (DynValue coroutine, DynValue parameter=default(DynValue)) void StartCoroutine (string name, DynValue parameter=default(DynValue))

string ScriptID get

uint InstanceID get

ulong RegionID get

SScene Scene get

SDatabase Database get

SMath Math get

SShared Shared get

SWebservice WebServices get

string RuntimeType get

bool InEditor get

float TimeSinceAwake get

Action< int > OnAvatarJoin

Action< int > OnAvatarLeave

Action< string, Table > OnScriptServerMessage

SScene
SDatabase
SMath
SShared
SWebservice

string get

Space.Log("Log")
--Clicking the object will make the server script log "Test Message" on all clients

--server script
function OnScriptServerMessage(key, table) 
  if key == "testKey" then
    Space.Log("Message:" .. table[1])
  end
end


--client script
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"Test Message"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
Space.SubscribeToNetwork("thekey")
Space.UnsubscribeFromNetwork("thekey")
Space.SendMessageToAllClientScripts("thekey",{"themessage"})
--Clicking the object by a single client will send a message to the server which triggers a message response to all clients

--server script--
function OnScriptServerMessage(key, table) 
  if key == "testKey" then
  Space.SendMessageToAllClientScripts("ServerResponse",{"message response to all client scripts in region that are subscribed to this key"})
  end

end

--client script--
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"Test Message"})  
end

OnReceiveFunction = function(SNetworkMessage)
  Space.Log(SNetworkMessage.Key)
  Space.Log(SNetworkMessage.Message[1])
end

Space.Network.SubscribeToNetwork("ServerResponse", OnReceiveFunction)
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
Space.SendMessageToClientScripts(playerID,"thekey",{"themessage"})
--Clicking the object by a single client will send a message to the server which triggers...
--a message response only to that specific client


--server script--


function OnScriptServerMessage(key, table) 
  if key == "testKey" then
    local sender = table[2]
    Space.SendMessageToClientScripts(sender,"ServerResponse",{"a message response to the clicker's client script in region that is subscribed to this key"})
  end
end


--client script--
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  id = Space.Scene.PlayerAvatar.ID
  Space.Network.SendNetworkMessage("testKey",{"Test Message", id})  
end

OnReceiveFunction = function(SNetworkMessage)
  Space.Log(SNetworkMessage.Key)
  Space.Log(SNetworkMessage.Message[1])
end

Space.Network.SubscribeToNetwork("ServerResponse", OnReceiveFunction)
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
Space.StartCoroutine(AFunctionName)
--Clicking the object on client will trigger a 3 second countdown on server script using coroutine


--server script--
function OnScriptServerMessage(key, table) 
  if key == "testKey" and table[1] == "Timer" then
    Space.StartCoroutine(TimerCoroutine)
  end
end

function TimerCoroutine()
  local time = 0

  while time < 3 do
    Space.Log(3-time)
    time = time + 1
    coroutine.yield(1)
  end

end

--client script--
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  Space.Network.SendNetworkMessage("testKey",{"Timer"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
scriptID = Space.ScriptID
--Clicking the object on client will make the server script log it's ScriptID

--server script--
function OnScriptServerMessage(key, table) 
  if key == "testKey" and table[1] == "ScriptID" then
    Space.Log(Space.ScriptID)
  end
end


--client script--
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  Space.Network.SendNetworkMessage("testKey",{"ScriptID"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
instance = Space.InstanceID
--Clicking the object on client will make the server script log only...
--if it's instanceID matches with client's instanceID

--server script--
function OnScriptServerMessage(key, table) 
  local instanceID = Space.InstanceID
  if key == "testKey" and table[1] == "ScriptID"  and table[2] == instanceID then
    Space.Log(instanceID)
  end
end



--client script--
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  local instanceID = Space.Scene.InstanceID
  Space.Network.SendNetworkMessage("testKey",{"ScriptID", instanceID})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
region = Space.RegionID
--Clicking the object on client will make the server script log only...
--if it's RegionID matches with client's RegionID

--server script--
function OnScriptServerMessage(key, table) 
  local RegionID = Space.RegionID
  if key == "testKey" and table[1] == "ScriptID"  and table[2] == RegionID then
    Space.Log(RegionID)
  end
end



--client script--
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
  local RegionID = Space.Scene.RegionID
  Space.Network.SendNetworkMessage("testKey",{"ScriptID", RegionID})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
Space.Scene
Space.Database
Space.Math
Space.Shared
Space.WebServices
type = Space.RuntimeType
IsInEditor = Space.InEditor
SecondsAwake = Space.TimeSinceAwake
--Clicking the object will make the server script log it's TimeSinceAwake on all clients

--server script
function OnScriptServerMessage(key, table) 
  if key == "testKey" and table[1] == "TimeSinceAwake" then
    Space.Log(Space.TimeSinceAwake)
  end
end


--client script
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"TimeSinceAwake"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
DateAndTime = Space.DateTimeUTC
--Clicking the object will make the server script log it's DateTimeUTC on all clients

--server script
function OnScriptServerMessage(key, table) 
  if key == "testKey" and table[1] == "DateTimeUTC" then
    Space.Log(Space.DateTimeUTC)
  end
end


--client script
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"DateTimeUTC"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
unixtime = Space.LocalTimeUnix
--Clicking the object will make the server script log it's LocalTimeUnix on all clients

--server script
function OnScriptServerMessage(key, table) 
  if key == "testKey" and table[1] == "LocalTimeUnix" then
    Space.Log(Space.LocalTimeUnix)
  end
end


--client script
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"LocalTimeUnix"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
unixtime = Space.ServerTimeUnix
--Clicking the object will make the server script log it's ServerTimeUnix on all clients

--server script
function OnScriptServerMessage(key, table) 
  if key == "testKey" and table[1] == "ServerTimeUnix" then
    Space.Log(Space.ServerTimeUnix)
  end
end


--client script
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"ServerTimeUnix"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
function OnAvatarJoin(playerID)
end
function OnAvatarJoin(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars
  Space.Log("Avatar with ID " .. id .. "has joined")
  Space.Log("Number of avatars connected: " .. numOfAvatars)
end
function OnAvatarLeave(playerID)
end
function OnAvatarLeave(id)
  local numOfAvatars = Space.Scene.ConnectedAvatars
  Space.Log("Avatar with ID " .. id .. "has left")
  Space.Log("Number of avatars connected: " .. numOfAvatars)
end
function OnScriptServerMessage(key, table) 

theKeyString = key
theSNetworkMessageTable = table

end
--Clicking the object will make the server script log "Test Message" on all clients

--server script
function OnScriptServerMessage(key, table) 
  if key == "testKey" then
    Space.Log("Message:" .. table[1])
  end
end


--client script
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  Space.Network.SendNetworkMessage("testKey",{"Test Message"})  
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
DateTimeUTC
LocalTimeUnix
ServerTimeUnix