This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

So I have this very simple line of code:

export (String, "Fire Rate", "Charge", "Cooldown", "Toggle") var recovery_type

The problem is that when I create a new resource with this script attached to it, it does show "Fire Rate" as the default value but printing it reveals that it's just an empty string.

In the editor, I can change this to a different value and then back to "Fire Rate" and it will show the arrow to revert it back to the default value... of "Fire Rate". But this new modified "Fire Rate" does show when printing the variable in testing.

So am I missing something? Or are you supposed to always set the value manually when exporting a list variable?

Godot version 3.4.4
in Engine by (16 points)

1 Answer

+1 vote
Best answer

You didn't specify default value. Exported variable is introduced as null. Editor just shows first option in the list, if it is not confirmed, it stays null.

But You can just do this :

export (String, "Fire Rate", "Charge", "Cooldown", "Toggle") var recovery_type = "Fire Rate"
by (8,188 points)
selected by

Now that you mention it, it does make sense that it works that way, it's just that the editor likes to mislead you into thinking the default value is selected. Thanks

Unfortunately, this type of strat doesn't seem to be working for Exported Arrays of dropdowns

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.