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, please submit a support ticket.

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

string AccessKey set

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

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)

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

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)

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

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)

Properties

PropertyName

string AccessKey set

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

Read API Keys Section

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

Last updated

Sinespace® is a registered trademark of Sine Wave Entertainment Ltd, All Rights Reserved.