Exported variables seem fragile

Godot Version

Godot Engine v4.3.stable.official

Question

hi, so ive havent really seen a lot of discussion on this topic, but maybe ive missed it.

ive been wondering if exporting variables is such a good idea. it’s fine if they’re the simpler data types and if you assigned them default values. but if you export say a dictionary or array or string, of not insignificant size, it is a problem because exported variables can basically break/disappear if you, whether intentionally or accidentally, change the name of the variable, or just accidentally delete the code in question. when you then Undo that (expect if you do it in the split second before the editor updates), you dont get the exported data back. this seems extremely scary to me. am i just doing something wrong or is this how it’s supposed to work. sorry if the question is kind of dumb, im not a great programmer so maybe i just dont understand how this works

there are definitely cases where exporting variables make sense but im nervous to carefully put in large amounts of data in, say, an exported Array knowing i could accidentally wipe all that out if i happen to select the code in question and press the wrong key at some point

im assuming you’re not really supposed to export variables of types like dictionary and array, but just given the option, to use at your own discretion. i wonder if veteran users can drop their wisdom on this

No, that’s how exported variables work, the problem here is how the engine will known the renamed variable means to be the same value? Also how the engine will known if you deleted the variable but you want to keep that data saved?

That’s indeed a problem with exported variables but can be mitigated with version control programs like git, if you accidentally lose your exported data you can reset the changes for the last saved version or manually edit the tscn file to readd them without lose your current work.

1 Like