Dynamic inventory

Hello,

Ok basically i have an inventory for my game. When you click on an item on the map, it will get added to your inventory. I’ve based it on the simple script that is in most inventory tutorials:

function addtoslot (item) {
    if (!item.found) {
        item._x = eval("itemslot"+itemslotnum)._x;
        item._y = eval("itemslot"+itemslotnum)._y;
        item.found = true;
        itemslotnum++;
}
}

The problem with this however is that if you use an item, then that slot will get skipped and remain empty. I basically want to have it so that you pick up an item, it will go to the first available slot. I know how to get it to stay at the slot etc. it’s just testing to see if theres an empty slot available. I thought of doing a hittest at that slot to see if there was another object there, if there was then hittesting the next slot. But with 16 slots and a lot of items i can’t see that being very clean. I hope that makes sense to you all =D any advice is much appreciated.

Grant.