I have an ItemList that is dynamically filled with names of files that I have on disk. For some reason those names get saved statically. Like… I can look into the editor and find those names even though the itemList should be empty. At runtime those turn into duplicate entries.
The _ready function is called once every time the node is added to the node tree. Since the class has a @tool annotation, that means every time the scene is opened in the editor, in addition to when it is loaded by the actual game.
I don’t use this class in the game. The plugin works kind of like Dialogic. I use the plugin to generate objects that I use in game. So I go to the plugin, do something without ever starting the game, then close Godot and for some reason when I restart Godot the items will be part of the resource as shown in the pictures.
The add_item function adds to an array and that array has the @export annotation. That’s why you can see it in the editor.
The thing is that exported variable values are serialized and saved as part of the scene. Remove the annotation and it will not save when you save the scene or exit the godot editor
Now that I’m thinking about it, it’s weird that the items only duplicated once. I would expect them to keep accumulating every time you open and close the editor. Unless you deleted them manually every time I guess.