Godot Version
v4.6.stable.official [89cea1439]
Question
I want to export a Dictionary whose keys are members of an enum and whose values are Arrays of Resources.
extends Node
#D_allows is a Dictionary of things allowed by the Item
enum D_allow_key {
NATIVE_DAMAGE_ATTR,
NATIVE_TO_HIT_ATTR,
DAMAGE_TYPE
}
@export var D_allows : Dictionary[D_allow_key,Array] = {}
The key being typed to my enum works well. Now I want to type the valueArray, because without a type, I can’t select/drag a Custom Resource to the value :
The direct approach faces the ‘Nested typed collections are not supported’ error :
@export var D_allows2 : Dictionary[D_allow_key,Array[Resource]] = {}

Reading Lindbrum, I tried to use @export_custom with a hint_string :
@export_custom(PROPERTY_HINT_DICTIONARY_TYPE, “int:D_allow_key;28:24/17:Resource”) var D_allows : Dictionary[D_allow_key,Array] = {}
But I can’t find the Variant.Type for enums in the list because enums are no Variant (see below : it works with TYPE_INT and PROPERTY_HINT_ENUM, “4/2”). I put in an int in the example above to ensure I can drag a Resource into the nested Array : I can !
I tried to circumvent the problem by defining an enum property as explained by Leif in the Wind.
@export_custom(PROPERTY_HINT_DICTIONARY_TYPE, str(“%d:%d/%d:” + D_allow_key_list) % [TYPE_ARRAY, TYPE_INT, PROPERTY_HINT_ENUM] + “:D_allow_key;28:24/17:Resource”) var D_allows : Dictionary[D_allow_key,Array] = {}
Problem is, the second argument of @export_custom must not only be a String, but also a constant :
So I went and typed the whole thing literally :
@export_custom(PROPERTY_HINT_DICTIONARY_TYPE, “4/2:NATIVE_DAMAGE_ATTR,NATIVE_TO_HIT_ATTR,DAMAGE_TYPE;28:24/17:Resource”) var D_allows : Dictionary[D_allow_key,Array] = {}
It works !
Problem is, now I lost the benefit of having an enum in the first place. I have to type in every new value of D_allow_key in the @export_custom hint_string.
Everything seems to be in place, except the hint_string of @export_custom won’t accept variables, even if they evaluate to Strings, and it cannot defer the hint to the typed definition placed after the variable declaration (where Dictionary[D_allow_key,Array] = {} actually hints to the D_allow_key enum members).
I could go and try to write the whole \_get\_property_list() like Leif in the Wind, but I would like to know beforehand whether/why @export_custom can’t offer the functionality I’m looking for.
Any clever way to go about this without tripping again into a five-hour ‘eadbang is also welcome.





