I have a structure called “inventory” which can hold string variables. Here is the inventory the player has:
index | count |
---|---|
apple | 3 |
banana | 0 |
orange | 2 |
wheat | 0 |
wood | 0 |
This should display in-game as:
Notice how the oranges move up in the inventory, despite bananas being after it. Bananas, Wood, and Wheat isn’t shown because it has a value of 0. How could I replicate an infinite inventory such as this one, that can hold as many inventory child variables as possible?
The list should also update in real time if one of the values change, and if they are set to 0, they should disappear entirely.