Class PlayerArray

Object
   |
   +--PlayerArray

class PlayerArray


PlayerArray is a sophisticated data structure intended to function both like an Array and a Hashtable. It maintains a list of players that can be accessed either by looping through the values or by addressing them by name.

For example, assume we have three players: Bob, Tim, and Joe. The following examples are both valid methods of looking up the player "Tim".

//Assume that "players" is an instance of PlayerArray
for(var i=0; i<players.length; i++)
{
    if(players[i].name == "Tim")
    {
         game.log("Tim was at index #" + i + ".");
    }
}

//Prints "player.name = Tim"
game.log("player.name = " + players["Tim"].name);
You can also find the names of all the players in the array by looping through it with the "for(var in array)" statement. For example:
//Prints out "Bob", "Tim", and "Joe"
for(var i in players)
{
    game.log(i);
}

Defined in PlayerArray.js


Field Summary
 Number length
          The number of players in this array.
 
Constructor Summary
PlayerArray ()
            Not available.
 

Field Detail

length

Number length

Constructor Detail

PlayerArray

PlayerArray()