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'.
int CountCopiesOfItem (int itemID)
Function Description
void AddToHotbar (int index, int itemID)
Adds the first found instance of itemID to the players hotbar entry at slot 'index'.
void RemoveFromHotbar (int index)
Remove item at slot index from Hotbar
void RequestRefresh ()
Forces a check for external changes to the users inventory, can only be called once every 60 seconds
bool Authorized get
Returns true if player has accepted access authorization request to his inventory
[] Items get
Returns the array of the users current inventory items
void Authorize (Closure onAuthorized=null, Closure onRejected=null)
int CountCopiesOfItem (int itemID)
void AddToHotbar (int index, int itemID)
void RemoveFromHotbar (int index)
void RequestRefresh ()
bool Authorized get
SInventoryItem[] Items get
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.AuthorizedinvItems = Space.Inventory.Itemsvoid 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'.
void LoadProfile (Closure onFinished)
Load the profile of player
ActivePlayerProfile get
Property Description
void LoadProfile (Action< SUserProfile > onFinished) void LoadProfile (Closure onFinished)
SUserProfile ActivePlayerProfile get
onFinished
Callback Function
onFinished(SUserProfile) is called once profile is loaded
Space.Profile.Authorize()
--or
Space.Profile.Authorize(AnOnAuthorizeFunction)
--or
Space.Profile.Authorize(AnOnAuthorizeFunction, AnOnRejectedFuncton)function onFinished(SUserProfile)
--
end
Space.Profile.LoadProfile(onFinished)
Space.Profile.ActivePlayerProfilevoid (int id)
int (int questID)
void (int id)
void (int questID, int step)
void (int questID)
void (int id)
void (int id)
bool (int id)
void StartQuest (int id)
Function Description
int GetQuestStep (int questID)
Function Description
void ResetQuest (int id)
Function Description
void SetQuestStep (int questID, int step)
Function Description
void CompleteQuest (int questID)
Function Description
void AbortQuest (int id)
Function Description
void AwardAchievement (int id)
Function Description
bool HasAchievement (int id)
Function Description
bool (int groupID)
SGroupInfo (int groupID)
void (int groupID, bool force=false)
void (int groupID, bool force=false)
SGroupInfo[] get
bool IsMemberOf (int groupID)
Whether is a member of this group.
IsMember = Space.Groups.IsMemberOf(675)SGroupInfo GetGroupInfo (int groupID)
Get the group info by groupID.
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)
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)
SGroupInfo[] Membership get
Return an array with all the groups this player is a member of
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)--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)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.
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.
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.
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.
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)
string AccessKey set
This API Key needs to be set before any of the SEconomy functions will work.
void DeductSilver (int amount, Action< bool > onFinished=null) void DeductSilver (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.
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"