rex_board
Introduction
This plugin is a data structure of 2d array(x,y)+1d hash-table(z), to store the logical position of chess. This 2d array could be an orthogonal, isometric or hexagonal tile map combined with rex_board_squareTx or rex_board_hexTx plugin.
This plugin is a data structure of 2d array(x,y)+1d hash-table(z), to store the logical position of chess. This 2d array could be an orthogonal, isometric or hexagonal tile map combined with rex_board_squareTx or rex_board_hexTx plugin.
- rex_board + rex_board_squareTx = orthogonal or isometric, or staggered
- rex_board + rex_board_hexTx = hexagonal
Usage
Setup layout
User should put one of board-layout plugin
If the project has more then one boards, and each board has different board-layout, they need to assign board-layout object manually by "Action:Setup layout".
User should put one of board-layout plugin
- rex_board_squareTx - orthogonal/isometric/staggered layout
- rex_board_hexTx - hexagonal layout
If the project has more then one boards, and each board has different board-layout, they need to assign board-layout object manually by "Action:Setup layout".
Boundary
The boundary could be set by "Width" and "Height" at properties table. Or use "Action:Set board width", "Action:Set board height".
"Expression:BoardWidth", "Expression:BoardHeight" could be used to get current boundary.
The boundary could be set by "Width" and "Height" at properties table. Or use "Action:Set board width", "Action:Set board height".
"Expression:BoardWidth", "Expression:BoardHeight" could be used to get current boundary.
Logical position
Each chess or tile has a logical position (x,y,z). Each logical position only could have one instance(chess/tile).
x and y are number type,
Each chess or tile has a logical position (x,y,z). Each logical position only could have one instance(chess/tile).
x and y are number type,
- The boundary of x is start at 0, to board.width-1.
- The boundary of y is start at 0, to board.height-1.
- z=0 is a tile. It will be used to find tile instance by other plugin/behavior.
- other z values are chess.
Retrieve each cell
Sample capx
Uses "Condition:For each cell" to retrieve all cells, get current logical X, logical Y index by ( Expression:CurLX, Expression:CurLY ).
Sample capx
Uses "Condition:For each cell" to retrieve all cells, get current logical X, logical Y index by ( Expression:CurLX, Expression:CurLY ).
Retrieve each LZ at LXY
Uses "Condition:For each LZ at LXY" to retrieve all LZ at LXY, get current LZ by Expression:CurLZ.
Uses "Condition:For each LZ at LXY" to retrieve all LZ at LXY, get current LZ by Expression:CurLZ.
Create chess
Use one of these actions to create and add tile (lz = 0) or chess instance on the board,
Check the configure "X at (0,0)", "Y at (0,0)" in layout plugin (rex_board_squareTx, or rex_board_hexTx) if the created chess does not appear.
Tile (z=0) is a base logical position since any chess should stand above a tile.
Use one of these actions to create and add tile (lz = 0) or chess instance on the board,
- Action:Create tile
- Action:Create chess
- Action:Create chess above tile, or
- Action:Fill tiles, to fill all tiles
Check the configure "X at (0,0)", "Y at (0,0)" in layout plugin (rex_board_squareTx, or rex_board_hexTx) if the created chess does not appear.
Tile (z=0) is a base logical position since any chess should stand above a tile.
Add tiles
Use one of these actions
Use one of these actions
- Action:Add tile
- Action:Add chess, or Action:Add chess by UID
Remove/Destroy chess
The chess will be remove from board when instance had been destroyed automatically, at next tick of destroying action (C2 engine will destroy instance at the tick end). So that the destroyed chess will be still on the board at current tick.
User should call one of these actions
Or use "Action:Destroy chess" to remove and destroy chess in one action.
The chess will be remove from board when instance had been destroyed automatically, at next tick of destroying action (C2 engine will destroy instance at the tick end). So that the destroyed chess will be still on the board at current tick.
User should call one of these actions
- Action:Remove chess
- Action:Remove chess by UID
Or use "Action:Destroy chess" to remove and destroy chess in one action.
Clean board
"Action:Reset board" will clean the board to empty.
"Action:Reset board" will clean the board to empty.
On the board
"Condition:On the board" could be used to test if the chess is on the board.
"Condition:On the board" could be used to test if the chess is on the board.
Maximum or minimum of logic X, logic Y of all chess
Get maximum logic X/Y of all chess by "Expression:MaxLX", "Expression:MaxLY". Get minimum logic X/Y of all chess by "Expression:MinLX", "Expression:MinLY".
Get maximum logic X/Y of all chess by "Expression:MaxLX", "Expression:MaxLY". Get minimum logic X/Y of all chess by "Expression:MinLX", "Expression:MinLY".
Move chess
- Action:Move chess
- Action:Move chess by UID
- Action:Move chess to xyz
- Action:Move chess to xyz by UID
- Action:Move chess to z
Kicked chess
The chess will be kicked after chess created/added/moved, since each logical position only could have one chess.
"Condition:On chess kicked" will be triggered when chess kicking, to pick kicked chess.
Mostly, the kicking should not happened, so that this condition might be used for debugging during development stage.
To avoid kicking, user could assign z-index of each chess by its uid (for example, "uid"+chess.uid), so that all z-index of chess will be different.
The chess will be kicked after chess created/added/moved, since each logical position only could have one chess.
"Condition:On chess kicked" will be triggered when chess kicking, to pick kicked chess.
Mostly, the kicking should not happened, so that this condition might be used for debugging during development stage.
To avoid kicking, user could assign z-index of each chess by its uid (for example, "uid"+chess.uid), so that all z-index of chess will be different.
Logical collision/overlapping
"Condition:On collision" will be triggered if the chess move to the same logical (x,y) position of other chess.
"Condition:Is overlapping" is used to test if chess are overlapping with the same logical (x,y) position.
The z index of these chess will be different for logical collision/overlapping. It will trigger "Condition:On chess kicked", if the z-index of these chess are the same, see previous section.
"Condition:On collision" will be triggered if the chess move to the same logical (x,y) position of other chess.
"Condition:Is overlapping" is used to test if chess are overlapping with the same logical (x,y) position.
The z index of these chess will be different for logical collision/overlapping. It will trigger "Condition:On chess kicked", if the z-index of these chess are the same, see previous section.
Swap chess
"Action:Swap chess by UID" could swap the logical position of two chess by uid. This action will not change the physical position, user need to move them manually.
"Action:Swap chess by UID" could swap the logical position of two chess by uid. This action will not change the physical position, user need to move them manually.
Empty cell
- Condition:Is empty
- Condition:Is occupied
Get empty cell
Sample capx , Sample capx (on tiles)
"Condition:Has any empty cell", "Condition:Has any empty cell on tiles" are used to check if there has any empty cell on the board, user could get the logical (x,y) of an empty cell by "Expression:EmptyLX", and "Expression:EmptyLY".
"Condition:Pick an empty cell", "Condition:Pick an empty cell on tiles" are used to get an empty cell randomly, the logical (x,y) of picking result could be got by "Expression:EmptyLX", and "Expression:EmptyLY", too.
If all cells are occupied, these two conditions will return false.
There has another way to pick an empty cell, see the section of "Examples" in rex_chess.
Sample capx , Sample capx (on tiles)
"Condition:Has any empty cell", "Condition:Has any empty cell on tiles" are used to check if there has any empty cell on the board, user could get the logical (x,y) of an empty cell by "Expression:EmptyLX", and "Expression:EmptyLY".
"Condition:Pick an empty cell", "Condition:Pick an empty cell on tiles" are used to get an empty cell randomly, the logical (x,y) of picking result could be got by "Expression:EmptyLX", and "Expression:EmptyLY", too.
If all cells are occupied, these two conditions will return false.
There has another way to pick an empty cell, see the section of "Examples" in rex_chess.
SOL
Pick all chess
These actions/conditions could pick all chess, put them into their SOL.
These actions/conditions could pick all chess, put them into their SOL.
- Condition:Pick all chess, Action:Pick all chess
- Condition:Pick chess, Action:Pick chess
Pick chess according to logical position
These actions/conditions could pick a chess which at specific logical (X,Y,Z) position.
These actions/conditions could pick a chess which at specific logical (X,Y,Z) position.
- Condition:Pick chess at Logic X,Y,Z, Action:Pick chess at Logic X,Y,Z
- Condition:Pick chess at LX, Action:Pick chess at LX
- Condition:Pick chess at LY, Action:Pick chess at LY
- Condition:Pick chess at LZ, Action:Pick chess at LZ
- Condition:Pick chess at Logic X,Y, Action:Pick chess at Logic X,Y
- Condition:Pick chess inside a square, Action:Pick chess inside a square
Pick chess above tiles
These actions/conditions could pick chess above based tile.
These actions/conditions could pick chess above based tile.
- Condition:Pick chess above tile, Action:Pick chess above tile
- Condition:Pick chess above tile UID, Action:Pick chess above tile UID
Pick neighbor chess
Sample capx
These actions/conditions could pick neighbor chess.
Or use "Expression:DIR2UID" to get the neighbor chess (uid) by origin chess uid and direction.
"Condition:Are neighbors (UID)" could be used to test two chess are neighbor or not.
The code direction could be get in layout plugin (rex_board_squareTx, or rex_board_hexTx).
Sample capx
These actions/conditions could pick neighbor chess.
- Condition:Pick neighbor chess, Action:Pick neighbor chess
Or use "Expression:DIR2UID" to get the neighbor chess (uid) by origin chess uid and direction.
"Condition:Are neighbors (UID)" could be used to test two chess are neighbor or not.
The code direction could be get in layout plugin (rex_board_squareTx, or rex_board_hexTx).
Logical position and chess UID
These expressions could get logical position by chess UID, return (-1) if the chess is not on the board.
These expressions could get logical position by chess UID, return (-1) if the chess is not on the board.
- Expression:UID2LX
- Expression:UID2LY
- Expression:UID2LZ
Z-index
"Expression:LZ2UID" could get the chess at a z-index above other chess assign by uid. i.e. the same logical (x,y) but different z-index.
"Expression:LXY2ZCnt", "Expression:UID2ZCnt" could be used to get the number of chess at the same logical (x,y) position (with different z-index, of course).
"Expression:LZ2UID" could get the chess at a z-index above other chess assign by uid. i.e. the same logical (x,y) but different z-index.
"Expression:LXY2ZCnt", "Expression:UID2ZCnt" could be used to get the number of chess at the same logical (x,y) position (with different z-index, of course).
Get physical position
These expressions could get physical position by logical position, or chess. Return (-1) for invalid value caused by out of boundary, or chess does not exist.
These expressions could get physical position by logical position, or chess. Return (-1) for invalid value caused by out of boundary, or chess does not exist.
- Expression:LXY2PX
- Expression:LXY2PY
- Expression:LXYZ2PX
- Expression:LXYZ2PY
- Expression:UID2PX
- Expression:UID2PY
- Expression:PXY2NearestPX
- Expression:PXY2NearestPY
Angle or distance of chess
"Expression:UID2LA" could get the angle of logical axis from Origin chess to FaceTo chess, return (-1) for invalid angle. For example, the valid angles in square board are 0, 90, 180, 270.
"Expression:LogicDistance" could get logical distance of two chess, return (-1) if chess are not on the board.
"Expression:UID2LA" could get the angle of logical axis from Origin chess to FaceTo chess, return (-1) for invalid angle. For example, the valid angles in square board are 0, 90, 180, 270.
"Expression:LogicDistance" could get logical distance of two chess, return (-1) if chess are not on the board.
Wrap
Sample capx
Set "Wrap" in properties table to "Yes", or set by "Action:Set wrap mode" could wrap this board. The leftmost tile will become the neighbor of rightmost tile. It will effect the result of picking neighbors.
Sample capx
Set "Wrap" in properties table to "Yes", or set by "Action:Set wrap mode" could wrap this board. The leftmost tile will become the neighbor of rightmost tile. It will effect the result of picking neighbors.
This image is the result of picking neighbors in 8x8 hexagonal board with "Wrap" to "Yes".
String symbol chess
Sample capx
A chess could be an instance, or replaced by a unique string symbol to reduce the amount of instances.
Call "Action:Add chess by UID" to add a string symbol into this board. Do NOT uses symbol string which composed by number characters ( "0" - "9" ) only, these kinds of string will be used in C2 engine for UID table of instances.
Although string symbol is not a real instance, it still could use these expressions
Sample capx
A chess could be an instance, or replaced by a unique string symbol to reduce the amount of instances.
Call "Action:Add chess by UID" to add a string symbol into this board. Do NOT uses symbol string which composed by number characters ( "0" - "9" ) only, these kinds of string will be used in C2 engine for UID table of instances.
Although string symbol is not a real instance, it still could use these expressions
- Get logical position (x, y, z) by ( Expression:UID2LX , Expression:UID2LY , Expression:UID2LZ )
- Get string symbol at logic position by Expression:LXYZ2UID, or Expression:LZ2UID
- Get ideal physical position (x, y) by ( Expression:UID2PX, Expression:UID2PY )
- Get string symbol at physical position (x, y) by Expression:PXY2UID
Infinity board
Sample capx
Set property "Infinity" to "Yes" to become an infinity board. In this mode-
Sample capx
Set property "Infinity" to "Yes" to become an infinity board. In this mode-
- There are not boundaries (board width or board height), chess could be place at any logic position.
- Wrap mode is ignored,
- Some actions or conditions are not supported like "Action:Fill tiles".
Save&Load
This plugin support official save/load system, so that it could be saved&loaded automatically.
This plugin support official save/load system, so that it could be saved&loaded automatically.