Godot Version
4.4.1 stable
Question
I’m a relative newcomer to Godot, but have been in the game industry for years, and have experience with scripting (not a coder though, no like C++ experience). I’m taking on what is probably too big of a personal 2D ARPG project, but whatevs.
I have an inventory system, where the items are created and tracked using custom resources, basically an ItemData class that extends resource with export vars for the name, type, texture, etc. I make a .tres for each unique item and set the variables on the .tres. Items can be used either in the inventory or the gameplay scene (off of an action input).
I was hoping to make a series of scripts/resources for each item effect (heal, damage nearby enemies, spawns a projectile, etc.) and assign the effect resource as one of the export variables so it can be read off the ItemData, and triggered. BUT I was hoping to make just one Heal_Effect (as an example) and be able to set the values on the Item .tres (the apple heals 1/2 heart, the apple pie heals 2 hearts, etc) as “sub” exported variables on the effect resource variable.
When I tried this:
A. You can only set exported vars on a Resource embedded in a Resource in the Inspector if you set a specific class as the var type. This means I have to set it to say ItemEffect and make a single ItemEffect class.
B. When I did this, and changed the ‘heal_value’ on one item resource it changed on all of them, even if I had local to Scene checked on everything (I suspect it only works on resources already attached to scenes, not raw .tres files)
So, do I need to make an ItemEffect class, and make a .tres based on it for EACH item with unique values even if the underlying code is the same? The ItemEffect would just have the triggering and init functions and each resource would need to have unique coding?
Any other thoughts on how to achieve this in a more modular manner.