Godot Version
v4.4 stable.official.4c311cb11
Question
What is the best way to manage unique inventory between multiple storage chests, using data resources?
First of all, I am using Michael Games’ “Make a 2D Action & Adventure RPG in Godot 4” YouTube tutorials for my base game architecture. Great tutorials by the way. My code is a heavily modified version of this. I have implemented a click based movable inventory system like Stardew Valley uses (click an item in the inventory then click another item or empty space and it will either place the item or swap). I like the feeling of this over drag-n-drop.
I have come to the point of starting storage chests and would like some input from others. I am not finding much info out there that relates to my setup. I’ll try my best to explain my setup.
-My Layout
My player inventory is player_inventory.tres , which is an InventoryData Resource, consisting of SlotData(slot info). This was created by right clicking the folder, create new resource, then selecting InventoryData. All of my code for adding, removing, sorting, etc. of items is in the InventoryData script. The inventory slots also transfer signals (func _on_gui_input) thru this script for mouse button action (left/right click).
I then have a grid container with a script that controls the UI aspect of the inventory. It populates given the content of player_inventory.tres.
-Chest Creation
When creating the storage chest, I can create a new resource using InventoryData to store the items in, storage_inventory.tres for example. It works great except all my storage chests have the same inventory because they all look back to this same storage_inventory.tres resource file. Is there a way to instantiate this or am I looking at this all wrong?
I have also created a chest with an array of SlotData to use in place of the InventoryData resource, which allows each chest to have its own unique inventory. This option, however disables my ability to get the left/right click signals from my inventory slots, which is needed.
Thanks in advance for feedback!