Sure... Phone-Address look-up. In Era.
PHP Code:
Phones.phoneMap = TMap.newInstance();
// In various locations around the world
Phones.phoneMap.put("553-4234", this );
// To phone...
otherPhone = Phones.phoneMap.get( "553-4234" );
otherPhone.chat = "*ring* *ring*";
Merger...
Item System:
PHP Code:
items = TMap.newInstance();
items.put( itemID, {quant, state});
merger = function( key, val1, val2 ){ return {val1[0] + val2[0], val1[1] || val2[1]}; }
items = TMap.merge( items, TMap.newInstance( {{ itemID, quant, 0 }}, merger );
... There are many situations that it could come up.
What I use it for is to have a cumulative effects from the clothing that the player uses.
For instance, let's say 'Speed'...
PHP Code:
Special Boots = TMap.newInstance( {{"Speed", 5}});
Other Clothing = TMap.n... ...
mods = playerMods;
mods = TMap.merge( mods, racialMods );
for ( clothes: all worn clothes )
mods = TMap.merge( mods, clothes.mods );
player.speed = mods.get("Speed");
This is done FOR-ALL possible (and future) attributes:
PHP Code:
temp.modList = temp.mod.toArray();
for ( temp.mod: temp.modList )
clientr.(@ temp.mod[0] ) = temp.mod[1];