Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

[Feature Request] Additional event in regards to save file

My apologies if this event already exists, since I'm currently not using the very latest version. I may need an event in the future that executes on save file clear.

Use case:
I have a custom monobehavior script that tracks certain game data.
This data has to persist through saves and scenes.
I don't want to constantly sync with global varialbe since it involves some encoding.
Now I register to events "on before save game" and "on before change scene".
During these events I write my data to global variable.

The issue:
When restarting the game (while you're currently ingame), this produces undesired behaviour.
This produces the sequence:
1) Save file is cleared
2) On Before change scene is called, which results in my script dumping all the data to relevant global variable.
3) New game is started, but save file isn't clean and the associated GVar is full of data from previous other save file

So an event that triggers "on before save file clear" would be very helpful. Then my script would just clear it's own data and would end up writing empty data during the "On Before change scene" that was triggered by restart. "On Before change scene".

Maybe there is a way to detect this situation without adding another event, that's why I tried to describe the event sequence in as much detail as possible

Comments

  • I'm confused about your mention of the "save file being cleared". Is this in reference to your own save file / script?

    And when restarting the game, you're using Engine: End game to do so? When this is called, all global and per-scene is cleared. If I'm understanding you correctly, you'd like a hook to run a custom event at the same time?

  • edited May 2019

    "I'm confused about your mention of the "save file being cleared". Is this in reference to your own save file / script?"
    No, this is the reference to global variables.

    1) My script has "Jimmy johnny" written in it. (It exists similarly to GameEngine, as in there is a single instance of it in every scene.)
    2) I call Restart through Engine: End game
    3) Global variables, player character and other save data is cleared
    4) OnBeforeSceneChange is triggered. My script dumps "Jimmy johnny" into a global variable during this event
    5) Scene is changed. Every variable is cleared except for the one where "Jimmy johnny" was placed.

    If I'd get an event callback on step #3 I could clean up my script during that step.

    "If I'm understanding you correctly, you'd like a hook to run a custom event at the same time?"
    Yes

  • Very well.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!