Godot Trick: Dynamic Enum Picker

This post is somehow related with the post of last year. One thing is annoying when you edit a large amount of resources (typically the case when you make a RPG): Every time you add an enum to an autoload, you have to reload the project so it reload the definition. This can get pretty grating after a while.
Similarly you had no way to add entries to a dynamic database and this being reflected within Godot Editor.
There is actually a way to have dynamic entries through the Godot Editor, using the property list.
var dynamic_value: int
func _get_property_list():
var properties := [{
"name": "dynamic_value",
"type": TYPE_INT,
"usage": PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE,
"hint": PROPERTY_HINT_ENUM,
"hint_string": get_dynamic_values()
}]
return properties
func get_dynamic_values():
## This don't have to be static/known at compilation
## You could be: var result = MyDatabase.search("Goblins")
return "Carots:0, Potatoes:1, Turnip:2"
This can be very useful if you don’t want to reload scripts containing ids all the time.