Godot Version
Godot 4.2
Question
Hello again! I’m stuck once more in how to access and change data in resources.
The problem is that I’m trying to make a simple crafting system, where all it does it add and subtract an amount in the inventory list of items. So it’s just changing numbers of variables basically.
I have two resource classes that I’m working with. “Item” and “Recipe”. These I’ve tried manipulating by making two scripts: “get_item” and “craft_item”.
Get_item works well! It has an export variable for what Item I need to add, and fetches information fine from it, just changing the “amount” of the resource. No problems there:
Craft_item gives me trouble though, because a Recipe resource contains Item resources within one of its variables, for information on what items to subtract, and what will be the result:
I’ve tried making this slapdash code to make it reference the data in the nested “result” resource, but am failing. Godot keeps giving me a ‘nil’ error for the contents of those variables.
How do access this information nested in the recipe resource? is there something I should be loading in, that I’m missing?
(Don’t mind the commented out line for now, I think I’ve turned that into nonsense)