Hello,

I am using the tutorial for the simple inventory system located here..

I've got it working fine within my game I'm making. However, if the player uses an item in the middle (or, in fact, anywhere other than the end) of the inventory list, it leaves a gap where it once was. How would I go about making each of the found items in the inventory move back one slot upon the player using an item?

I realise this will have to detect from which slot the item was in before it was used and then shift all the items after it backwards a slot, but I'm not sure how to go about doing this.

Does anyone know how I could achieve this? Or know of any better tutorials for inventory systems that include this feature already?

Thanks.

Here's my code for reference:

First frame:
Code:
currentslotnum = 1;
function addToslot (item) {
	if (!item.found) {
		item._x = _root.navbar.nav2["slot" + currentslotnum]._x;
		item._y = _root.navbar.nav2["slot" + currentslotnum]._y;
		item.found = true;
		currentslotnum++;
	}
}
Each item (this example is on the first key):
Code:
on (release) {
	_root.addToslot (_root.navbar.nav2.firstkey);	
}
The scenery that the item is used with:
Code:
on (release) {
	this.navbar.nav2.firstkey._visible = false;
	currentslotnum--;
	}
}