No Parameters
VALUE(BOOLEAN) | TRUE if no current player is set, FALSE otherwise. |
This function tests if no current player is set in the context. No player is set if a SetPlayer() call was never made. If no current player is set, this returns TRUE. However, if a 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.
CurrentPlayerIs() — Tests if the current player is the one provided.