Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If the human player uses cheats, they can switch to a different player during the game so bear this in mindwhich will in turn cause the value of selectedPlayer to change.

Example

Code Block
themeEclipse
languagejavascript
titleWork out if human is looking at me
linenumberstrue
function am_i_being_watched() {
  if (selectedPlayer == me) { // human has infiltrated my AI brain!
    console("Hey! Stop watching me, go back to your own game!");
  }
}
setTimer("am_i_being_watched",10000); // check every 10 seconds
Code Block
themeEclipse
languagejavascript
titleMake a note of which player the human should be...
linenumberstrue
// take a snapshot of which player the human is at the start of the game
var humanPlayer = selectedPlayer;
 
// has human switched players?
function checkForPlayerSwitch() {
  if (selectedPlayer != humanPlayer) { // human has switched players
    console("Naughty, naughty!");
  }
}
setTimer("checkForPlayerSwitch",10000); // check every 10 seconds

See also

  • me – the player the current script is running as
  • playerData[] – data about each player (excluding scavengers)
  • scavengerPlayer – the player ID of scavenger faction
  • startPositions[] – start positions for each player (excluding scavengers)