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

rex_parse_leaderboard

Plugin, ACE table, Discussion thread
Dependence:
rex_parse_initialize

Introduction
Leader board built on parse.

Tutorial by Jomo
_

Usage

Sample capx
Prepare
Add 
rex_parse_initialize to set api id and javascript key.
Class name
"Class name" in properties table is the "table name" shown at dash board.
Authentication (optional)
It is recommend that getting UserID after login in rex_parse_authentication.

Get score
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.
Post score
Call "
Action:Post score" to post score. It will save the score and other information indexed by UserID
.
"Condition:On post complete" will be triggered if posting successfully, otherwise "Condition:On post error" will be triggered.
Get posted player name by "Expression:PostPlayerName" under "Condition:On post complete" condition.

Post score if greater/if less
Sample capx
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.
Add to score
Sample capx
Call "Action:Add to score" to add a value to current score.

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

Pages
Ordered scores would be divided into pages, which started from page 0 (0-based).
Call one of these action
to fetch score of players from parse server.
  • 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 data, then use "Condition:For each rank", or "Condition:For each rank in a range" to retrieval score of each fetched player. During this condition, get information by these expressions-
  • Expression:PageIndex, which is 0-based
  • Expression:CurPlayerRank , which is 0-based
  • Expression:CurPlayerName
  • Expression:CurPlayerScore
  • Expression:CurExtraData
  • Expression:CurUserID
  • Expression:LoopIndex, loop index in current for each loop
Or get these information by rank index with these expressions-
  • Expression:Rank2PlayerName
  • Expression:Rank2PlayerScore
  • Expression:Rank2ExtraData
The rank index could be got by UserID with "Expression:UserID2Rank"
.
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.

Leader board ID
The plugin could support more then one leader board by changing the ID of leader board to other value. These leader board are put under the same "class name".
The initial ID of leader board
is set at "ID" field in properties table. Call "
Action:Set leaderboard ID" to change the ID of current leader board. It will also reset the page index to 0, and clean all data.

Get ranking of UserID
Sample capx
Call "
Action:Get ranking" to send a request to get ranking of UserID.
"
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.

Get users count
Call "Action:Get users count" to get total saved users count. The result is put at "Expression:LastUsersCount" under "Condition:On get users count", otherwise "Condition:On get users count error" if requesting failed.

Access permission
Sample capx
Set property "Access permission" to "Private" to protect score item only could be wrote by owner after authentication. Raise
"Condition:On post error" if item is not allowed to write.
Set "Access permission" to "Public" or
authentication fail will not set any access permission. i.e any user could over write all score items.

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.

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