I created an array to hold the names of all the items you can carry in your inventory for my game. I'm trying to make it so that duplicates of items don't show up in your inventory. The string value of the item being added to your inventory should only be added if it doesn't already exist in your bags. I set this up like this.
if(characterClass.itemArray.indexOf(characterClass.ratTeeth) > 1)
{
characterClass.ratTeeth += 3;
} else {
characterClass.ratTeeth += 3;
characterClass.itemArray.push(characterClass.ratTeethStr);
trace("Rats Teeth :" , characterClass.ratTeeth);
updateInv()
}
If i'm doing something wrong could someone please tell me? Thank you!