Autoload variables getting freed without touching them?

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

Hello.
I am basically using 2 scenes at the moment:

  • a “hub” where one thing you can do is create characters (just allocating stat points in fact)
  • a “fight scene” where characters previously created are send to various missions

To save the characters “data” from one scene to another, I use an autoload to store the character ability values (name, level, power,…).

Basically when in the hub, creating a character will automatically add him with his stats to an Array.
When I want to move to the action scene, the variables (name, level, power…) of these characters are used to create a playable/movable character on the mission scene.

This side works fine for the moment. However after the mission is complete, when I use get_tree().change_scene() to move back to the hub, the data in the autoload are consistently replaced by “null” data.
The thing is when I am on the mission screen the only time I use the autoload is at the very beginning to create the playable characters for the mission (and I just use the values to set the playable character name or stats so they are not modified by this), but after that I never touch the data so I don’t understand where and when the data stored in the autoload are being freed…

I have been reading various comments about weakref but I am having trouble really understanding it and from the bit I got, it wouldn’t solve my issue as I don’t need to check if the data have been freed or not as they shouldn’t have been in the first place

This is probably not quite clear, but would anyone have a guess as to what it could be?