All pages
Powered by GitBook
1 of 6

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

SProfile

Index

Functions Index

Function Name

Properties Index

Property Name

Functions

Authorize

void Authorize (Closure onAuthorized=null, Closure onRejected=null) void Authorize (Action onAuthorized=null, Action onRejected=null)

Requests access to profile functions, must be called prior to attempting to access profile. As soon as the player has accepted the request, the Authorized attribute will be 'true'.

Parameter
Type
Description

LoadProfile

void LoadProfile (Closure onFinished)

Load the profile of player

Parameter
Type
Description

Properties

ActivePlayerProfile

ActivePlayerProfile get

Property Description

void Authorize (Closure onAuthorized=null, Closure onRejected=null) void Authorize (Action onAuthorized=null, Action onRejected=null)

void LoadProfile (Action< SUserProfile > onFinished) void LoadProfile (Closure onFinished)

SUserProfile ActivePlayerProfile get

onFinished

Callback Function

onFinished(SUserProfile) is called once profile is loaded

SUserProfile
Space.Profile.Authorize()
--or
Space.Profile.Authorize(AnOnAuthorizeFunction)
--or
Space.Profile.Authorize(AnOnAuthorizeFunction, AnOnRejectedFuncton)
function onFinished(SUserProfile)
--
end
Space.Profile.LoadProfile(onFinished)
Space.Profile.ActivePlayerProfile

Player

SGroup

Index

Functions Index

Function Name

Properties Index

Property

Functions

IsMemberOf

bool IsMemberOf (int groupID)

Whether is a member of this group.

Parameter
Type
Description

GetGroupInfo

GetGroupInfo (int groupID)

Get the group info by groupID.

Parameter
Type
Description

JoinGroup

void JoinGroup (int groupID, bool force=false)

Shows player a prompt to join specified group. If force is true, the user will not be shown a prompt. (force parameter is white-label only)

Parameter
Type
Description

LeaveGroup

void LeaveGroup (int groupID, bool force=false)

Shows player a prompt to leave specified group. If force is true, the user will not be shown a prompt. (force parameter is white-label only)

Parameter
Type
Description

Properties

Membership

[] Membership get

Return an array with all the groups this player is a member of

bool IsMemberOf (int groupID)

SGroupInfo GetGroupInfo (int groupID)

void JoinGroup (int groupID, bool force=false)

void LeaveGroup (int groupID, bool force=false)

SGroupInfo[] Membership get

SGroupInfo
SGroupInfo
IsMember = Space.Groups.IsMemberOf(675)
--Clicking this object will check if player is a member of group with ID 350
--and it will turn green if you are, or red turn if you are not
thisObject = Space.Host.ExecutingObject


OnClickFunction = function()
  if Space.Groups.IsMemberOf(350) then
  thisObject.Renderer.Material.SetColor("_Color", Color.Green)
  else
  thisObject.Renderer.Material.SetColor("_Color", Color.Red)
  end
end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
groupInfo = Space.Groups.GetGroupInfo(675)
--Clicking this object will turn green if your in group 350 is "Owner"
--and red if your role is not "Owner"
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
local groupInfo = Space.Groups.GetGroupInfo(350)
  if groupInfo.Role == "Owner" then
  thisObject.Renderer.Material.SetColor("_Color", Color.Green)
  else
  thisObject.Renderer.Material.SetColor("_Color", Color.Red)
  end

end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
Space.Groups.JoinGroup(675)
--Clicking this object will check if player is in group 350 
--and will prompt the player to leave if they are a member
--and will prompt them to join if they are not a member
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  if Space.Groups.IsMemberOf(350) then
  Space.Groups.LeaveGroup(350)
  else
  Space.Groups.JoinGroup(350)
  end
end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
Space.Groups.LeaveGroup(675)
--Clicking this object will check if player is in group 350 
--and will prompt the player to leave if they are a member
--and will prompt them to join if they are not a member
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
  if Space.Groups.IsMemberOf(350) then
  Space.Groups.LeaveGroup(350)
  else
  Space.Groups.JoinGroup(350)
  end
end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
groups = Space.Groups.Membership
--Clicking this object will turn green if you are in at least 1 group
--and red if you are in no groups
thisObject = Space.Host.ExecutingObject

OnClickFunction = function()
local groups = Space.Groups.Membership 
 if #groups > 0 then
 thisObject.Renderer.Material.SetColor("_Color", Color.Green)
 else
 thisObject.Renderer.Material.SetColor("_Color", Color.Red)
 end

end


thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)

SEconomy

SEconomy

API Keys

The SEconomy class gives us the ability to transfer silver or issue silver rewards from Sinespace's vault. Therefore, for the below methods to work, you will need to first set the AcessKey which is an API Key given by Sinespace.

To request an API Key,

Here's two API Keys which are pre-generated and available to the public:

b9184836-9c73-486a-b058-a0a668b860f7 Maximum 5000 silver per 24 hours per user, AND allows up to 5000 to be deducted as well. Works only on Preview.

11f55b74-69ee-4dd3-8983-17c466912beb Maximum 500 silver per 24 hours per user. Works on Preview or Live.

Note: The above two keys work with DeductSilver() and AddSilver(). You'll need an API Key which has your specific required function enabled.

Index

Functions Index

Function Name

Properties Index

Property

Functions

DeductSilver

void DeductSilver (int amount, Action< bool > onFinished=null) void DeductSilver (int amount, Closure onFinished=null)

Deducts amount of silver from player's silver balance. You can also bind a function which will be called when operation is finished (optional), which also returns a Boolean if the operation succeeded or not (for example, API Key limit reached). This method requires AccessKey to be set first.

Parameter
Type
Description

AddSilver

void AddSilver (int amount, Action< bool > onFinished=null) void AddSilver (int amount, Closure onFinished=null)

Adds amount of silver to player's silver balance. You can also bind a function which will be called when operation is finished (optional), which also returns a Boolean if the operation succeeded or not (for example, API Key limit reached). The source of the silver is Sinespace. This method requires AccessKey to be set first.

Parameter
Type
Description

TransferSilverFrom

void TransferSilverFrom (int amount, string reason, int to, Action< bool > onFinished=null) void TransferSilverFrom (int amount, string reason, int to, Closure onFinished=null)

Removes 'amount' of silver from player avatar's balance and sends it to 'to' avatar ID. You can also bind a function which will be called when operation is finished (optional), which also returns a Boolean if the operation succeeded or not (for example, API Key limit reached). This method requires AccessKey to be set first.

Parameter
Type
Description

IssueReward

void IssueReward (int id, Action< bool > onFinished=null) void IssueReward (int id, Closure onFinished=null)

Issues reward 'id' to player Avatar. You can also bind a function which will be called when operation is finished (optional), which also returns a Boolean if the operation succeeded or not (for example, API Key limit reached). This method requires AccessKey to be set first. (white-label grid only)

Parameter
Type
Description

Properties

AcessKey

string AccessKey set

This API Key needs to be set before any of the SEconomy functions will work.

SInventory

Index

Functions Index

Function Name

void DeductSilver (int amount, Action< bool > onFinished=null) void DeductSilver (int amount, Closure onFinished=null)

void AddSilver (int amount, Action< bool > onFinished=null) void AddSilver (int amount, Closure onFinished=null)

void TransferSilverFrom (int amount, string reason, int to, Action< bool > onFinished=null) void TransferSilverFrom (int amount, string reason, int to, Closure onFinished=null)

void IssueReward (int id, Action< bool > onFinished=null) void IssueReward (int id, Closure onFinished=null)

string AccessKey set

id

int

The ID of the reward to player avatar.

onFinished

Action< bool >

A function name that will be called with a boolean parameter that tells us if the operation succeeded or not.

please submit a support ticket.
Read API Keys Section
function onFinished(success)
--
end
Space.Economy.DeductSilver(50, onFinished)

--or
Space.Economy.DeductSilver(50)
--the below script will deduct 50 silver from the person who clicks the object containing it
--(Example: A ticket vendor that requires 50 silver to proceed)
--[The AccessKey we are using below is for preview servers only]

thisGameObject = Space.Host.ExecutingObject

Space.Economy.AccessKey = "b9184836-9c73-486a-b058-a0a668b860f7"


OnPaymentDone = function(success)
  if success then
  Space.Log("You have paid 50 silver. Please proceed.")
  else
  Space.Log("Failed. AccessKey limit may have been reached")
  end
end

OnClick = function()
Space.Economy.DeductSilver(50, OnPaymentDone)

end


thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Buy ticket (50 silver)"
thisGameObject.Clickable.OnClick(OnClick)
function onFinished(success)
--
end
Space.Economy.AddSilver(50, onFinished)

--or
Space.Economy.AddSilver(50)
--the below script will deduct 50 silver from the person who clicks the object containing it
--(Example: A ticket vendor that requires 50 silver to proceed)
--[The AccessKey we are using below is for preview servers only]

thisGameObject = Space.Host.ExecutingObject

Space.Economy.AccessKey = "b9184836-9c73-486a-b058-a0a668b860f7"


OnPaymentDone = function(success)
  if success then
  Space.Log("You have paid 50 silver. Please proceed.")
  else
  Space.Log("Failed. AccessKey limit may have been reached")
  end
end

OnClick = function()
Space.Economy.DeductSilver(50, OnPaymentDone)

end


thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Buy ticket (50 silver)"
thisGameObject.Clickable.OnClick(OnClick)
function onFinished(success)
--
end
Space.Economy.TransferSilverFrom(10, "A reason", 23239829,onFinished)

--or
Space.Economy.TransferSilverFrom(10, "A reason", 23239829)
--the below script will make the object a clickable that gives 10 silver to another avatar
--(Example: Silver transfer)
--[The AccessKey we are using below is for preview servers only. Please read the API Keys section above.]

thisGameObject = Space.Host.ExecutingObject

Space.Economy.AccessKey = "b9184836-9c73-486a-b058-a0a668b860f7"



done = function(success)
    if success then
   Space.Log("10 Silver sent")
 else
   Space.Log("failed")
    end
end
 
OnClick = function()
local avatars=Space.Scene.Avatars
Space.Economy.TransferSilverFrom(10, "testing", avatars[1].ID, done)
end

thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
function onFinished(success) --success parameter is optional here
Space.Log(success)
end

Space.Economy.IssueReward(12345,onFinished)

--or

Space.Economy.IssueReward(12345)
Space.Economy.AccessKey = "b9184836-9c73-486a-b058-a0a668b860f7" 

void (Closure onAuthorized=null, Closure onRejected=null)

int (int itemID)

void (int index, int itemID)

void (int index)

void ()

Properties Index

Property Name

bool get

SInventoryItem[] get

Functions

Authorize

void Authorize (Closure onAuthorized=null, Closure onRejected=null)

Requests access to inventory functions, must be called prior to attempting to access inventory. As soon as the player has accepted the request, the Authorized attribute will be 'true'.

Parameter
Type
Description

CountCopiesOfItem

int CountCopiesOfItem (int itemID)

Function Description

Parameter
Type
Description

AddToHotbar

void AddToHotbar (int index, int itemID)

Adds the first found instance of itemID to the players hotbar entry at slot 'index'.

Parameter
Type
Description

RemoveFromHotbar

void RemoveFromHotbar (int index)

Remove item at slot index from Hotbar

Parameter
Type
Description

RequestRefresh

void RequestRefresh ()

Forces a check for external changes to the users inventory, can only be called once every 60 seconds

Parameter
Type
Description

Properties

Authorized

bool Authorized get

Returns true if player has accepted access authorization request to his inventory

Items

SInventoryItem[] Items get

Returns the array of the users current inventory items

 Space.Inventory.Authorize()
 --or
 Space.Inventory.Authorize(onAuth, onRej)
--this script shows you how to use this function to take authorization and immediately
--take action based on the result all in a single prompt (a click in this case)

function ifno()
  Space.Log("not authorized")
  end

function ifyes()
Space.Log("authorized")
--your next steps go here
  end
function click()
  
  Space.Inventory.Authorize(ifyes,ifno)

end


Space.Host.ExecutingObject.AddClickable()
Space.Host.ExecutingObject.Clickable.OnClick(click) 
numOfCopies = Space.Inventory.CountCopiesOfItem(38384839)
Space.Inventory.AddToHotbar(2, 23423523)
Space.Inventory.RemoveFromHotbar(2)
Space.Inventory.RequestRefresh()
isAuthorized = Space.Inventory.Authorized
invItems = Space.Inventory.Items
Authorize
CountCopiesOfItem
AddToHotbar
RemoveFromHotbar
RequestRefresh
Authorized
Items

SQuests

Index

Functions Index

Function Name

Functions

StartQuest

void StartQuest (int id)

Function Description

Parameter
Type
Description

GetQuestStep

int GetQuestStep (int questID)

Function Description

Parameter
Type
Description

ResetQuest

void ResetQuest (int id)

Function Description

Parameter
Type
Description

SetQuestStep

void SetQuestStep (int questID, int step)

Function Description

Parameter
Type
Description

CompleteQuest

void CompleteQuest (int questID)

Function Description

Parameter
Type
Description

AbortQuest

void AbortQuest (int id)

Function Description

Parameter
Type
Description

AwardAchievement

void AwardAchievement (int id)

Function Description

Parameter
Type
Description

HasAchievement

bool HasAchievement (int id)

Function Description

Parameter
Type
Description

void StartQuest (int id)

int GetQuestStep (int questID)

void ResetQuest (int id)

void SetQuestStep (int questID, int step)

void CompleteQuest (int questID)

void AbortQuest (int id)

void AwardAchievement (int id)

bool HasAchievement (int id)

Space.Quests.StartQuest(1001211)
currentStep = Space.Quests.GetQuestStep(1001211)
Space.Quests.ResetQuest(1001211)
Space.Quests.SetQuestStep(1001211, 5)
Space.Quests.CompleteQuest(1001211)
Space.Quests.AbortQuest(1001211)
Space.Quests.AwardAchievement(1001211)
hasAchievement = Space.Quests.AwardAchievement(1001211)