Revamping Inventory Management: From Chaos to Order
How I am using Dictionaries to manage the AoI Inventory system!
Vinciware
9/8/20232 min read
Section 1: Streamlined Object Management
In the past, I had hundreds of inventory game objects cluttering the environment, just waiting to be activated. Now, I have a single game object that can be duplicated and deleted as needed. This change eliminates unnecessary clutter and optimizes resource usage, making your game run smoother.
Section 2: Unique Inventory Items
Each item in your inventory boasts a unique identifier integer. When you access your inventory, the game calculates how many of these unique items you possess and generates the corresponding number of inventory buttons. This ensures that your inventory is always up to date and running as efficiently in the background as possible!
Section 3: Personalizing Inventory Buttons
Initially, all the inventory buttons are blank and identical. However, the new system employs two unique dictionaries to remedy this.
Dictionary 1: Key-Value Pair for Quantity
The key in this dictionary is the item's identification number.
The value is a digit representing the quantity of that item in your inventory.
When you open your inventory, a loop creates each inventory button and uses the quantity value to edit the text associated with that button to display the quantity in your inventory.
Dictionary 2: Key-Value Pair for Icons
In this dictionary, the key is still the item's identification number.
The value now contains a string specifying the icon image file name.
This feature allows each button to have a unique appearance. For example, if you have coins in your inventory, the dictionary pair might look like this: "dictionaryName(1, "coinIcon.png")."
the loop then goes to a file containing all the icon images and displays the correct one for each button.
Conclusion:
I decided to make these changes early-on to prevent it from becoming a task too vast to overcome.
The transition from a chaotic inventory system to a well-organized and visually appealing one will enhance the gaming experience. Your "cooler" now contains neatly packed Tupperware containers, making it easier to find and manage your lunch items. Likewise, this revamped inventory system ensures that every item is accounted for and easily identifiable. With these improvements, your gaming journey promises to be smoother and more enjoyable than ever before.
Remember, the best way to support Age of Irata's development is to add it to your steam wishlist!
Imagine a disorganized brown paper bag stuffed with your lunch items. Now envision a sleek cooler, with each food group neatly organized in unique Tupperware containers. To sum up what I have been working on the past couple days... I've been creating coolers out of the original brown paper bag that was my old inventory system.
09-09-2023: Inventory progress update!
I was able to delete ALL of the inefficient code related to the inventory descriptions and replace it with a much cleaner system. Again... by utilizing dictionaries. I sound like a broken record at this point, but they really are such an amazing tool!
Previously, I had a unique method for each inventory description that would run and update the text on button click. Now I have 1 function that intelligently updates the description text based on the Key value associated with each button.