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

rex_backendless_leaderboard

Plugin, ACE table, Discussion thread
Dependence:
rex_backendless_api

Introduction
Leader board built on
backendless.
_

Usage
Prepare
Add 
rex_backendless_api to set api id and secret key.
Class name
"Class name" in properties table is the "table name" shown at dashboard.

Authentication (optional)
It is recommend that getting UserID after login in rex_backendless_authentication.


Primary keys
Each score saved in leaderboard table is indexed by ( boardID, userID ), or ( boardID, userID, tag ) if property "Tag" is set to non-empty string.
These keys are also shown in dashboard named "boardID", "tag", and "userID".
BoardID
Set boardID in properties table "ID" or set by "Action:Set board ID". Read it back by "Expression:BoardID.
Tag
Tag is an optional filter. Set tag in properties table "Tag" or set by "Action:Set tag". Read it back by "Expression:Tag". Set this tag value to empty string "' to ignore it.
UserID
Assign userID in each "Action:Post score", see next section.

Post score
This plugin supports posting score after
authentication or without authentication.
Post score after authentication
Sample capx

Call "Action:Post score" to post score after logging, fill the parameter "UserID" to "Expression:UserID" of rex_backendless_authentication.
"Condition:On post" will be triggered if posting success, otherwise "Condition:On post error" will be triggered.
Get posted userID by "Expression:PostUserID" under "Condition:On post" condition.

Link to owner table
Set property "Owner class name" to the table name of linked owner data.
Set table name to "" to ignore data linking, set table name to "Users" to link to the system "Users" table.
Post score without authentication
Sample capx

Set parameter "UserID" to an unique string in "Action:Post score" to post score.
Post score if greater/if less
Call "
Action:Post score" and set "
Post condition" to "if greater", "if less" to post the score only when the new score is greater/less then saved score.

Get score
Sample capx
Call "
Action:Get score" to get score.
"
Condition:On get score" will be triggered while got score, otherwise "Condition:On get score error" will be triggered.
Get score by "
Expression:LastScore" under "Condition:On get score" condition. Return "" if requested userID does not exist.


Requesting ranks
Order
Set "
Order" to "Large to small" or "Small to large" in properties table, to order scores.
It will sort by updated time if scores are the same.

Period
Set time-frame before getting scores by property "Period" or set by "Action:Set period". To get scores during -
  • Current day,
  • Current week ,
  • Current month,
  • Current year,
  • All-time.
Pages
Ordered scores would be divided into pages, which started from page 0 (0-based).

Call one of these actions
to fetch scores -
  • Action:Update current page
  • Action:Turn to next page
  • Action:Turn to previous page
  • Action:Turn to page
"Condition:On update" will be triggered when received scores. Otherwise "Condition:On receive error" will be triggered.
Retrieve scores
Uses "Condition:For each rank", or "Condition:For each rank in a range" to retrieval each fetched scores. Get information by these expressions under this condition -
  • Expression:CurScore
  • Expression:CurUserID
  • Expression:CurUserData( key ), this expression is only valid when "Link to user table" sets to "Yes".
  • Expression:PageIndex, which is 0-based
  • Expression:CurUserRank, which is 0-based
  • Expression:LoopIndex, loop index in current for each loop
Or get these information by rank index with these expressions -
  • Expression:Rank2Score( rank )
  • Expression:Rank2UserID( rank )
  • Expression:Rank2UserData( rank, key )
The rank index could be got by UserID with "Expression:UserID2Rank".
Last page
Get ranking count of current page by "Expression:CurRankingCount". "Condition:Last page" will return true if current page is the last page, which the ranking count is less than requested count.
Start from any index
Call "
Action:Request in a range" to show ranks started from any index. Do not mix this action with pages type request described at previous section.
Other things are the same as "Pages" in previous section.

Get ranking of UserID
Sample capx
Call "
Action:Get ranking" to send a request to get ranking of UserID. It will search all scores page by page until finds the score.
"
Condition:On get ranking" will triggered while found ranking of UserID, otherwise "Condition:On get ranking error" will be triggered.
Get the result of ranking by "Expression:LastRanking", requested UserID by "Expression:LastUserID" under "Condition:On get ranking". Return (-1)
if requested userID does not exist.

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

Compare with rex_firebase_leaderboard plugin
This plugin and
rex_firebase_leaderboard plugin both support leader board. This plugin is good at showing ranks in pages, but this plugin could not show
top N ranks in real-time.
Compare with rex_parse_leaderboard plugin
Some fields like user name, extra data had been removed in this plugin. And the configuration of data security between parse and backendless are different, too.
One last important thing, parse service will be closed.

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