[AS2] Inventory System

what is the best way I can make an inventory system? The Canadian gave me a good start but I have no clue how to work with the code he gave me >.< I need a system where I would be able to manipulate the items the player has. I want to try to keep it text based meaning not applying images to each and every item.

Just the word and how many of that item the player would have. Any help would be appreciated. The only way I can think of is creating a global variable for each and every item in the game but that code would be too long. I’m looking for a simpler approach.

Here is how my method would look (I use the PHP code tags cuz it helps with identifying key actions and such)


_global.item1 = 0
_global.item2 = 0
_global.item3 = 0
_global.item4 = 0
_global.item5 = 0
_global.item6 = 0
_global.item7 = 0
_global.item8 = 0
_global.item9 = 0
_global.item10 = 0

there is going to be more than 10 items just put 10 down as an example.
The reason I’m looking for something easier is becuase when I put in my save code I would have to reffer to all those variables. Unless this would work


for(i=0;i<10;i++){
   if(i == 3){
      if(_global.item* == 2){
      _global.item* -= 1;
      }
   }
}

but something in the back of my head says that the above code would not work. Plus i think the above code is more complicated than my first code. At least when identifying items.