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

rex_token

Plugin, ACE table, Discussion thread
Dependence: None


Introduction
Round-robin player index, used in turn based game.

Usage
Sample capx
Players list
Before get player index or player ID, it needs to define players list first.
Players list is a list of playerID, which could be defined in properties table "
Player ID list". For example, set "Player ID list" to "1,2" will define the players list to [ 1, 2 ].
i.e. the player ID is number 1 and number 2.
Or call "Action:Append" to append player ID at runtime. In this mode, remember to set "
Player ID list" to "" (empty).
Current player
Current player is the player who owned the token.
Follow these steps to get current player ID.
  1. Call "Action:Next" to pass token to next player
  2. Get the current player ID by "Expression:CurrID", or player index by "Expression:CurrIndex"
Player index
Since the expected start player is the first player in the player list. i.e. the index 0 in players list ( 0-based ). The initial index should be set to (-1) in property "Initial index", or call "Action:Turn off" to set current player index to (-1) at runtime.
"
Condition:First index" / "Condition:Last index" will return true if current player is the first one / last one in players list.
Next player
Call "
Action:Next" to pass token to next player. Or call "
Action:Set next index" or "
Action:Set next ID" to pass token to the specific player. Or call "Action: Next random" to pass token to next random player.
Swap players
Call "
Action:Swap" to swap two player ID on players list.
Order
The index of next player would be increasing if set property "
Order" to "Increasing". Designer could inverse the order by "
Action:Reverse".

Remove players in players list
Call "
Action:Remove" to remove a player ID from players list. Or call "Action:Clean list" to remove all players from players list.
Index of player
Get player ID by "
Expression:Index2ID", or get player index by "Expression:ID2Index".

Save & load
This plugin supports official save&load feature. 
Players list could be exported by "
Expression:List2String" in string, and import player list into this plugin by "Action:Set list".
Debug
"
Condition:On player changing" will be triggered while token had been passed. Dump current player ID or player index under this event to see the changing of current player.

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