Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Overview

...

Excerpt

Stores the player ID your script is associated with...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
me

Values

The value of me

...

, which is read-only, will be an integer in the range -1 ≤ me ≤ Math.max(scavengerPlayer, maxPlayers):

ValueNotesGame version
-1

Means your script will receive events from all players

There is also a hackChangeMe() function in WZ 3.2 which allows you to set the value of 'me'.

Status
colourYellow
title3.2+
0The game host (person who started the game) is always player 0, regardless of what map position they start in.
Status
colourGreen
title3.1 b1+
1 → maxPlayersBetween 1 and 9 additional players in the game (human or AI)
Status
colourGreen
title3.1 b1+

<scavengerPlayer>

 

In scavfact.js, the value of 'me' will be same as scavengerPlayer.

  • If scavengers are enabled, the value will be 7 or maxPlayers+1, whichever is higher.
  • If scavengers are disabled, the value will be -1.
Status
colourGreen
title3.1 b1+

An additional global, selectedPlayer, allows you to determine which of the players the localhost human is playing as (remember the human can switch to different players using the Debug Menu).

rules.js in WZ 3.2+

Note: This is currently being discussed in forums.

In Warzone 3.2 and above, the value of 'me' defaults to -1 in rules.js. This means that all Events & Timers from all players will be received in rules.js. To work out which player is associated with rules.js, cache the value of selectedPlayer at the start of a game, for example:

Code Block
themeRDark
languagejavascript
linenumberstrue
var humanPlayer = selectedPlayer;

Even if the human changes to a different player via the Debug Menu, which would change the value of selectedPlayer, you're cached 'humanPlayer' variable will still contain the player the human was originally playing as at the start of the game.

Example

Code Block
theme

...

RDark
languagejavascript
title

...

Get a list of my droids...
linenumberstrue
// get a list of 

...

my droids

...


...

var 

...

myDroids = enumDroid(

...

me);
Div
classbox
Availability
Status
colourGreen
title3.1 b1+

Requires:

  • Warzone 3.1 Beta 1 or above
  • Updated in 3.2 to allow value of -1
Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5