Exporting an Array of a small data set inside a Resource

Godot Version

4.3

Question

So what I wanna do is effectively something like this where a resource contains an array full of instances of a pretty basic data set

#script A
class_name Data extends RefCounted

#I need this to be a flags so I can have multiple of them selected at a time
@export_flags("Combat", "Puzzle", "Exploration") var challengeType = 0   
@export_enum("Total", "Less_Than", "Greater_Than", "Equals") var comparisonType : int
@export var value : int
var valueModifier : int = 0

# script B
class_name Enemy extends Resource
@export_var array : Array[Data]

However this itself doesn’t work since an export can only be a built-in, a resource, a Node, or an Enum. I don’t think I want Data to be a resource cause that’s just gonna bloat the number of different files I have going on. I looked around a bit and a Dictionary might work but if it does then I don’t know how I would set it up if that makes sense.

If anyone has any ideas, either for the dictionary or some other method, on how to get this to work then that’d be greatly appreciated

enum Test {THIS, THAT, THEOTHER}
@export var example: Test

@export var example2: Array = [“This”, “That”, “TheOther”]

This is how you can export an enum and an array in a custom resource. They have to be declared separate. You can also use a dictionary if you have a need for it. If you are on Godot 4.4 you can use typed dictionaries as well. Which allow you to put two different variable types in your dictionary like an enum and an int if you wanted.

This isn’t necessarily true. Only if you save those Data Resources into disk it will happen. If you make it a Resource and only add/modify/remove it from the other Resource array then that Resource file will contain that information.

Just make it a Resource that’s the easiest way.