How to organise a backpack/inventory system

I’m having problems trying to think of a clean effective way of organising my backpack system. What I have currently is two folders, Hotbar and Backpack. The Hotbar has 5 folders inside of it titled 1, 2, 3, 4, 5 for each slot. That’s fine, however the backpack I want to allow players to have infinite slots in their backpack. So using this index system will create a problem I fear for the future.

Problem with indexing or using numbers. If I have say 10 items in my backpack, and I delete item number 3, now I have 9 items, titled

1
2
4
5
6
7
8
9
10

If I create a new item, do I just keep adding (so 11) or do I fill in that gap? Problem with filling in the gap is with my UI, the folder name is the LayoutOrder, so now that item will be put in an awkward spot in the inventory. I want it to go to the lowest spot on the list.

Another solution I thought of was just naming each folder the name of the item. That’d fall down hard tho too, as tables can’t store multiple items with the same key. So if slot 1 and 2 are both a “Sword” then it’d only save one, even tho the player has 2.

Any suggestions/help/adive is greatly appreciated :slight_smile:

1 Like

Have you considered organizing it with code instead of folders? Calling table.remove on a table for the backpack would shift everything for you.

1 Like

Well cause I have all my data (from their table) converted into folders/values, so its easily readable on the client, instead of having to fire remotes back and forth from the server