Imagine having 2 arrays.
1 array defines the items, values, worths, extras, like:
existing_items_array (static array of items, predefined during development)
itemID (Y0) | name(X0) | color (X1)
0 | sword1 | blue
1 | sword2 | red
2 | potionheal | green
3 | gold | yellow
Then you have a dynamic array for your users inventory:
InventoryID (Y0) | ItemID (X0) | amount(X1) | location (X2)
0 | 1 | 2 | chest
1 | 2 | 5 | belt
2 | 2 | 15 | chest
3 | 3 | 100 | backpack
4 | 3 | 1000 | chest
5 | 0 | 1 | equipped
2 red swords in the chest, 5 heal potions on his belt and 15 more in the chest, 100 gold in the backpack, and 1000 more in the chest. Also carries 1 blue sword which is equipped.
Say you pick up some gold, you add it to player inventory array where X0 = 3 (gold id) and X2 = backpack (location).
Imagine opening your inventory screen, select all items from array where X2 = backpack.
Say you open a chest next to it, show all items from user inventory array where X2 = chest.
You will need a method to move objects from one location to another, this is done with a temp variable.
Like moving your gold from your backpack to your chest.
Upon selecting the gold in the backpack, store the Y0 (inventory id) after clicking it.
Then if you place it in another position, update Y0 it's X2 (location).