How to store different structures in a structure

I have a concept of array with items, i.e. itemdatabase from which I get an index which I then use to reference my items in inventory and other places.

The problem I have is that some items are quite different with different properties.
So they have different properties (which I need to read and write).

From a coding point of view, I add new properties as well so, regression testing is a pain because using a single structure occasionally breaks code.

I have an item type that I thought might be used to point me to the item type’s structure , however, this means I need to use enums OR array indexes for lookups, ( array indexes have the mutation problem and enums means I compare strings to enums.

It all feels a bit wonky.

Any advice is appreciated. (I do BP only)

Well it almost seems like you are recreating a relational database with this

Attributes would be a second set of struct with a parent child relationship.

Attribute would need to contain the parents id (its foreign key).

Honestly I’d simplify it overall. I wouldn’t pack all of that into a single parent struct.

Have an Inventory variable for each “type” of inventory item. Types would be items using the same data structure. As @3dRaven said… database. You’d have a table (variable) for each specific type following a strict field type structure (struct).

  • Health/Meds
  • Consumables
  • Ammo
  • Weapons
  • Gear
  • Armor

Keep the prototyping setup as simple as possible to reduce breaking. Once you figure out the final requirements, then start packing structures and arrays.

can you create structs on the fly like make array or make set?

No. You need to create the structure file, then create a variable to represent that structure in the actor class.