Export list from autoload

Godot Version



Is there a some-what easy way to get a list/dictionary keys or something from an autoload that I have setup, and have that be a drop-down list for an export?

For example I have

enum Resource = {

And I want to be able to easily reference this list whenever I need to.
I have generator objects that I want to be able to easily just say “This give this resource” and then when you go to craft something I want to be able to just reference that list again. To my understanding enums are basically just dictionaries, so in theory I should be able to use .keys() to get an array of the keys, which in this case would be “Wood” and “Stone” but then you can’t use an array as a dropdown box for exported variables. If I have @export var Resource_Gained = Global.Resources.keys() then in the editor it simply says “Nil(Array)” Which I assume I don’t even want this to be an array, as I don’t want to edit the array itself but rather have a dropdown. I also can’t use something like ```enum Resource_Gained = Global.Resources.keys()" as the values for an enum themselves must be constant.

Don’t name it Resource as it may probably clash with the Resource class.

You can @export enums normally like: @export var resource_gained:Global.ResourceItem where ResourceItem is the name of your enum. You can see how to do it in the documentation here @GDScript — Godot Engine (stable) documentation in English

1 Like