How to save scene state?

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

I’m making point and click game like Fran Bow, where player can move between rooms. So I I’m changing rooms with change_scene(). When I go from room1 to room2 and then back to room1, all changes tat I made in room1 goes away.
So how tosave state of scene?
I should mae a variabels for every change that player can do and check them when room is loaded? Or there are a better way to save scene state?

:bust_in_silhouette: Reply From: crossbito

You could do a lot of things. For example, you could use a resource that contains all the variables the player can change. By loading the scene with the default resource, when the player makes changes and reloads the scene, you will have the player’s modifications. Alternatively, you can utilize global variables or have a main scene (the root scene) that is responsible for changing a child scene (the main scene) and saving the changes. Afterwards, you can load the scene with the saved modifications.

To me, the resource is perfect for that because you can use it in every node where you make changes, and all of them would have access to the modifications.