But how would I store the value for all the cards that I want in my game? How I was going to do it was through a massive array of dictionaries like the one above, stored in an autoloaded script e.g.
I want this because I will want to be able to pick a random common, defensive, or energy cost card and having a place where all the card values are stored will help with that.
If it helps to know each card also will have its own scene and a script as there are to many different things the cards will need to do for that to be general. Maybe I could store the scripts in one big array, then just store each card values in each card script, instead of having such a massive array? any ideas will be much appreciated.
If you create a script for every card you might aswell store that data in this script. You can create a “Resource” that holds an array or dictionary of all your card scenes. If a scene wants to access a card it can just preload this resource and access this scene through the resource.
In general Dictionaries are the most common way data is stored, since it is easy to read as a programmer and also efficient
Thanks for answering, so you are saying I should do something like this,
extends Resource
class_name cards
@export var card_scenes = []
Then whenever I create a card just add the card scene to this resource? The only problem is that after I have created this resource there is no option to add scenes
I will definitely set it up like that thanks, I was going to say how would I generate a random card as I don’t have an array of all my cards but I remember that groups exists. Meaning I can add all my cards to a group and get an list by calling SceneTree.get_nodes_in_group().