View Single Post
  #12  
Old 07-10-2010, 09:40 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well if you're making an equipment system there's quite a few ways you can store the information:

PHP Code:
enum SLOT
{
  
HEAD,
  
CHEST,
  
WEAPON,
  
FEET
}

function 
onCreated() {
  
this.equipment = {
    
"Helmet of Awesome",
    
"Golden Armorplate",
    
"Best. Sword. Ever.",
    
"Bunny Slippers"
  
};
  echo(
getHeadItem());
  
setHeadItem("Helmet of Change");
  echo(
getHeadItem());
}

function 
setHeadItem(item) {
  
this.equipment[SLOT.HEAD] = item;
}

function 
getHeadItem() {
  return 
this.equipment[SLOT.HEAD];
}

function 
getChestItem() {
  return 
this.equipment[SLOT.CHEST];
}

function 
getWeaponItem() {
  return 
this.equipment[SLOT.WEAPON];
}

function 
getFeetItem() {
  return 
this.equipment[SLOT.FEET];

enum is explained here.

or simply:

PHP Code:
function onCreated() {
  
this.equipment.head "Helmet of Laziness";
  
// etc.
  
echo(getHeadItem());
}

function 
getHeadItem() {
  return 
this.equipment.head;

Item systems that uses IDs instead of strings for their items would store the IDs in each slot instead.

Of course the examples above will have to be modified to meet your needs, and proper flags.
__________________
Quote:
Reply With Quote