Identifying equipped inventory in pure-data

I have a data-oriented inventory where each table describes the nature of an item that generally abides by the form {ID = 1, Q = 999} where ID summarises the item’s details in an n-digit number and Q represents the quantity. I want to denote some of these items as “equipped”.

It’s lost on me how to perform the aforementioned denoting of inventory as equipped. Although I do have a way to perform it which is to reserve “equipped” keys/tables in player data, I don’t think it’s a particularly sound solution. I want to know how developers may go about equipping items in pure-data.

These are the potential solutions I’ve marked up:

  • Include an E key for Equipped. This helps with saved data as I can load up inventory that a player has equipped for subsequent play sessions. My main concern is iterating through inventory to find out which items have an E during gameplay. As the inventory is an array, I would have to frequently iterate the entire inventory whenever equip states change if I want to do anything with the items in it?

  • Include keys for equipped inventory. For example, an equipped weapon would exist as the key “CurrentWeapon” in player data. The problem here is that the key here may hold a discrepancy with the copy in the inventory table. If I remove equipped item tables from inventory, it might be troublesome to work with, for example, in terms of inspecting your inventory including the equipped item in a convenient manner (have to check and/or add equipped items to inventory before parsing). Could possibly be mitigated with another associative ID but that seems like overengineering and a lot of overhead.

  • Separate inventory for equipped items. This seems like the soundest solution since it gets rid of discrepancies and I can join the tables together when needing to parse the entire inventory (for players, they’d see equipped items sorted first and then unequipped ones afterward), but having to join tables in itself seems like it’d take extra work to parse a full inventory. I also most likely would need to work around this for various features like sales but that’s a game design choice that’s not entirely relevant.

tl;dr Wondering how developers handle equipping for data-oriented inventories.

1 Like

After much thinking and research, including how inventory pipelines are established in other game engines (Unity most prominently), I’ve concluded that this is a relatively difficult topic and I should solve for deficiencies in the best solution with intuitive game design choices.

I’m going to create a separate inventory for equipped items that will both render and sort differently to standard inventory. Equipped inventory will always display ahead of unequipped inventory including when performing sorting and certain actions that can be performed on standard inventory will be unavailable to equipped inventory and vice versa.

Materials and resources are easy to resolve since they can’t be equipped but inventory such as weapons are a bit of a more difficult problem to tackle especially if there’s a feature where it’s in my best interest to have the inventories joined together (e.g. not requiring a specific equip state to upgrade an equippable item).

Always open to more pointers but I seem to raise complex problems whenever I post and I’m not really expecting any answers. :joy:

3 Likes