Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_backendless_savedata

Plugin, ACE table, Discussion thread
Dependence:
rex_backendless_api

Introduction
Save slots on backendless.


Usage
Sample capx

Concept
Each user has a dedicate slots set. Each slot is stores in a row, some keys are slot header.


Prepare
Add 
rex_backendless_api to set api id and javascript key.

Set Owner
Each user has a dedicate slots set. So first step is to set the owner user by "Action:Set owner". 
Set "User ID" to "
Expression:UserID" of rex_backendless_authentication.
Set keys of header
Header is some keys (fields) in a slot. Keys of header could be assigned in property "Header keys", or add keys by "Action:Add header key".

Load
Follow these steps to load a slot from cloud after set owner.

Get headers
1. Call "Action:Get all headers" to get all headers of this owner user. "Condition:On get headers" will be triggered if get all headers.
2. There are three ways to retrieve header for showing them at UI -
- a. "Condition:For each header", then get each slot name by "Expression:CurSlotName", and get value by "Expression:CurHeaderValue( key )".
Or retrieve each key of a header by "
Condition:For each key" under "Load - header" category, then read key and value by  "Expression:CurKey", and "Expression:CurValue".
- b. get value by "Expression:HeaderValue(  slotName, key )".
- c. get headers in items list by "
Expression:HeadersAsItemList", then put this list into rex_taffydb object.
Get body
3. Call "Action:Get body" with a slot name parameter to get selected slot body. "Condition:On get body" will be triggered if get body. "Condition:On get body error" will be triggered if got nothing.
4. Get body value by "Expression:BodyValue( key )".
Or retrieve each key of a body by "
Condition:For each key" under "Load - body" category, then read key and value by  "Expression:CurKey", and "Expression:CurValue".
If there is only a slot, the slot body could be load directly by step 3, 4.
After got headers, there are some conditions could be used to test if a slot is existed.
  • "Condition:Empty" is used to test if there is no slot.
  • "Condition:Is occupied" is used to test if a specific slot had been used.
Get value by key and default value
These expressions will read value by key,
  • Expression:CurHeaderValue( key )
  • Expression:HeaderValue( slotName, key )
  • Expression:BodyValue( key )
Or get value by key or return the default value if key does not exist.
  • Expression:CurHeaderValue( key , default_value )
  • Expression:HeaderValue( slotName, key, default_value )
  • Expression:BodyValue( key, default_value )
Or get all keys in JSON string
  • Expression:CurHeaderValue
  • Expression:HeaderValue( slotName ) , a header in JSON
  • Expression:HeaderValue( slotName ) , all header in JSON
  • Expression:BodyValue

Clean
Call "
Action:Clean slot" to clean a slot, header and body. Or call "Action:Clean all slots" to clean all slots.
"Condition:On clean" will be triggered if clean completed, otherwise "Condition:On clean error" will be triggered.
These actions will clean current loaded headers.


Save
Follow these steps to save a slot on server.
  1. Call "Action:Set value" or "Action:Set boolean value" to assign value with key.
  2. Call "Action:Save" to save this slot on cloud by slot name.
  3. "Condition:On save" will be triggered if saving completed, otherwise "Condition:On save error" will be triggered. Get last saved slot name by "Expression:LastSlotName", or error message by "Expression:ErrorMessage".
After saving, current loaded headers will be updated.

Last saved time
Last saved time would be stored at key "updated"
( Expression:KeyLastSaveTime ).
User could get the last saved time of a specific header by
Expression:CurHeaderValue( Expression:KeyLastSaveTime ), or get the last saved time of body by
Expression:BodyValue( Expression:KeyLastSaveTime ).
These would return an unixtimestamp, put this value into rex_date to get Year/Month/Date, Hour/Minute/Second.


Cache
Set property "Cache" to "Yes" to cache the objectId of slot. It could save 1 backendless access when saving slot.

Access permission
Data security is configured in dashboard. See this page for more detail.

Debug message
Current loaded slot values will be shown at debug panel.

Compare with rex_parse_savedata plugin
This plugin only uses 1 table to store header and body in a row. rex_parse_savedata plugin uses 2 tables.
One last important thing, parse service will be closed.

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About