Export Struct-like objects for arrays

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DemonBismuth

I have been bashing my head about this and can’t seem to figure it out. In another engine, I could make a struct, then make an array of that struct that I could then edit in the inspector. There seems to be no way of doing this that I can find in Godot.

I want to have a Resource that holds the starting Value and Type of multiple faces on a dice. For example, one side could have “2 Damage” while another has “Heal 3.” (this is a first-time godot experiment inspired by Slice&Dice). Every tutorial I watch however makes it seem like, if I want to do so, I’d have to make a completely new Resource for each combination of Value and Type (Damage 1 Resource, Damage 2 Resource, etc.)

class_name DiceResource extends Resource

class DiceFaceData:
	export var BaseValue = 0
	export(Resource) var Type = preload("Resources/DiceFaceTypes/Damage.tres")
	func _init():
		Type = 2
		BaseValue = preload("Resources/DiceFaceTypes/Damage.tres")

export(Array) var Faces = [DiceFaceData.new()]

I cannot get DiceFaceData to show up in the Inspector’s array, or be on the list of object types for an array. Extending Object doesn’t work. Extending Node means I have to instantiate it, which I don’t want to do for an editor-only Resource.

I find it hard to imagine Godot doesn’t have anything like this available. Is there anything I can load in the inspector as just data and not have to instantiate it? Another option is create two arrays, one with int and another Resource, but that seems inconvenient to fill out. Or should I just give up with Resources and make everything a Node attached to a Node attached to a Node? Thanks!