Is possible set append "type" (in _get_property_list()) as enum?

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

I’m trying to create a group of vars that will be displayed in editor only if “asset_type” is of a certain type (as told in this: https://forum.godotengine.org/31170/is-it-possible-to-export-expose-variables-conditionally). I don’t want to use TYPE_INT as the type, I want to use enum (to make the editor easier to read), but the editor don’t allow this. There is any way of do this?

enum types { SKILL, ITEM, EQUIPMENT }
func _get_property_list():
var property_list = []
property_list.append({
	"hint": PROPERTY_HINT_NONE,
	"usage": PROPERTY_USAGE_DEFAULT,
	"name": "group/asset_type",
	"type": TYPE_INT #here I want something like this-> "type": types
})
:bust_in_silhouette: Reply From: max.marauder

Can be done this way:

property_list.append({
	"hint": PROPERTY_HINT_ENUM,
	"usage": PROPERTY_USAGE_DEFAULT,
	"name": "group/asset_type",
	"type": TYPE_INT,
	"hint_string": PoolStringArray(types.keys()).join(",")
})
:bust_in_silhouette: Reply From: salihkallai

Godot 4 solution:

properties.append({
	"name": "hammer_type",
	"type": TYPE_STRING,
	"usage": PROPERTY_USAGE_DEFAULT, 
	"hint": PROPERTY_HINT_ENUM,
	"hint_string": ",".join(Enums.Type.keys())
})

Awesome solution, thanks! I just used this solution to make actions pickable:

properties.append({
	"name": "action",
	"type": TYPE_STRING_NAME,
	"hint": PROPERTY_HINT_ENUM,
	"hint_string": ",".join(InputMap.get_actions())
})

st_phan | 2023-06-03 07:24