Updating ENUM breaks every single child class

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

I have a parent class, that has an exported enum called type. I have some child classes that implement specific behaviours like CREATURE or SPELL each of which have around 100 children themselfs.
I recently wanted to add TRAP to the enum, but that broke everything, even though i took care not to change the older numbers assigned to the ENUM.

enum TYPE{
NONE = 0 ,
CREATURE = 1,
SPELL = 2,
BUILDING = 3,
FIELD = 4}

goes to

enum TYPE{
NONE = 0 ,
CREATURE = 1,
SPELL = 2,
BUILDING = 3,
FIELD = 4,
TRAP = 5}

Now every single child seems to be broken. While the editor shows the correct type, ingame every single scene is set to zero. I can confirm this with screenshots from the editor and the remote view of the scene in question. How do i fix this? Also how do i correctly update an ENUM without breaking already existing children?

Editor View

:bust_in_silhouette: Reply From: Inces

I had that recently. You just need to reload project. However, if You updated the enum in a way it showed compillation error for too long, your exported values will be reset to 0 and You will have to set each of them back manually.
Generally whenever You change core variable, You have to make it quick, so the compiller doesn’t report it as non-existing for a moment. If this would take too long, all inheriting classes will have their exported variables redone.
Also, whenever You update enum, You pretty much always have to reload project.

Unfortunatly reloading does not solve the problem. I can set the values in the editor, but ingame every type enum is 0. Can i do anything to fix this? Maybe use a different version of the Godot? Also why is this even happening. I though everything the editor shows, is represented in the game.

LeN3rd | 2023-02-17 01:14

OK, so after lots of debugging, turns out i had an onready var in my class, but i did most of the things before i added the nodes to the tree.

Regarding updating an ENUM, doing it quickly still seems kinda strange, doesn’t it? But it works for now. Thanks for answering.

LeN3rd | 2023-02-17 03:08

About doing it quickly :
I noticed, that after erasing variable from a script completely, compiller still remembers it. This feature must exist for purposes like changing a variable without needing to reentry every exported entry in every inheriting script. But if this memory is interrupted, all values are completely lost. I am not sure if time itslef interrupts this memory, but I suspect it is fragile and programmed to go away after some simple conditions are met.

Inces | 2023-02-17 13:28