SEconomy
On this classSEconomy
- SEconomy
- API Keys
- Functions
- Deduct
Silver - Add
Silver - Transfer
Silver From - Issue
Reward - Properties
- Acess
Key
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.
| Function | DeductSilver | Deducts amount of silver from player's silver balance. |
| Function | AddSilver | Adds amount of silver to player's silver balance. |
| Function | TransferSilverFrom | Removes 'amount' of silver from player avatar's balance and sends it to 'to' avatar ID. |
| Function | IssueReward | Issues reward 'id' to player Avatar. |
| Property | AcessKey | This API Key needs to be set before any of the SEconomy functions will work. |
Functions
DeductSilver
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.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | int | – |
| onFinished | Action< bool > | null |
| onFinished | Closure | null |
Returns
void
Example
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
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.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | int | – |
| onFinished | Action< bool > | null |
| onFinished | Closure | null |
Returns
void
Example
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
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.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | int | – |
| reason | string | – |
| to | int | – |
| onFinished | Action< bool > | null |
| onFinished | Closure | null |
Returns
void
Example
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)
IssueReward
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)
Parameters
| Parameter | Type | Description |
|---|---|---|
| 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. |
Returns
void
Example
function onFinished(success) --success parameter is optional here
Space.Log(success)
end
Space.Economy.IssueReward(12345,onFinished)
--or
Space.Economy.IssueReward(12345)
Properties
AcessKey
This API Key needs to be set before any of the SEconomy functions will work.
Example
Space.Economy.AccessKey = "b9184836-9c73-486a-b058-a0a668b860f7"



