Wait, i now get it. The insane amount of items is causing you to look through all items, if one is 0 it won't get displayed, so you have to look for the next... (I am doing it differently, the player has a specific amount of slots, and each slot can store one specific item, or another item...) You can try this:
Code: Select all
ITEMS_DISPLAYED [0] //holds amount of items already displayed
CUR_ITEM [0] //current 'item number' (let's say your attributes are called 'item_1', 'item_2',... one for each of the item types)
ITEM_AMOUNT [0] //amount of current item
//All Item names
ITEMS_NAME
{
...
}
DisplayItem[ ()
{
ITEM_AMOUNT=GetAttribute("item_" # CUR_ITEM,"Player");
if(ITEM_AMOUNT>0)
{
//Y position is calculated with the ITEMS_DISPLAYED
DrawText(ITEMS_NAME[CUR_ITEM],64,32+ITEMS_DISPLAYED*16,...);
DrawText(,64,32+ITEMS_DISPLAYED*16,...);
ITEMS_DISPLAYED=StringCopy(ITEMS_DISPLAYED)+1;
}
CUR_ITEM=StringCopy(CUR_ITEM)+1;
} ]
OR:
You use your idea of caching your items.
The thing with the 'unlimited array size' is an old problem in the programming area. You could just fake it by making an array that is EXTREMELY big (Like 500 entries or such) and covers ALL items the player has.
Then you can just use a SCROLLNUMBER and everything is fine. (And just update this giant array when you get into the inventory, it might also help if you used a flag that shows if the array is still valid like ARRAY_VALID, if you pick somthing up, it gets false and the next time you enter the inventory it gets updated)
EDIT: Ah Final Fantasy 4... it's so cool...