Parameter | Type | Description |
---|---|---|
PLAYER | PLAYER | The non-archetype player element to test against. |
VALUE(BOOLEAN) | TRUE if the current player matches, FALSE otherwise. |
This function tests if the current player is set to the provided player element. If the current player matches the provided player element, this returns TRUE. If it does not match, or no current player is set, this returns FALSE.
action general a_switchplayer1 named "switch 1";
action general a_switchplayer2 named "switch 2";
action general a_inc named "increment";
action general a_dec named "decrement";
action general a_quit named "quit";
player archetype p_all
{
init()
{
count = 0;
}
onAction(a_inc)
{
textln("Incrementing count...");
count = count + 1;
}
onAction(a_dec)
{
textln("Decrementing count...");
count = count - 1;
}
}
player p_player1 : p_all;
player p_player2 : p_all;
world
{
function printPlayer()
{
if (noCurrentPlayer())
textln("No current player is set.");
else
{
textln("current player is " + identity(player));
textln("player.count is " + player.count);
}
}
onAction(a_switchplayer1)
{
if (currentPlayerIs(p_player1))
textln(identity(p_player1) + " is already current.");
else
setPlayer(p_player1);
}
onAction(a_switchplayer2)
{
if (currentPlayerIs(p_player2))
textln(identity(p_player2) + " is already current.");
else
setPlayer(p_player2);
}
onAction(a_quit)
{
quit;
}
start()
{
textln("Type \"switch 1\" to switch to player 1.");
textln("Type \"switch 2\" to switch to player 2");
textln("Type \"increment\" to increment player.count");
textln("Type \"decrement\" to decrement player.count");
textln("Type \"quit\" to quit.");
printPlayer();
}
afterSuccessfulCommand()
{
printPlayer();
}
}
SetPlayer() — Sets the current player.
NoCurrentPlayer() — Tests if no current player has been set.