Page 1 of 1

Any way to update a global save variable when beating level?

Posted: Mon Feb 08, 2021 8:56 pm
by dragon3025
I noticed that my "globalSave" variables were being updated even my player dies or I exit through the menu. So I switched to transferring the global save variable into a local to make updates to the local, then transferring the updates back into global in "onExitLevel()", but I realized that "onExitLevel()" will also trigger when you exit from death or the menu.

Is there a way to only update a globalSave variable when the player enters a goal or goes off screen?

Re: Any way to update a global save variable when beating level?

Posted: Tue Feb 09, 2021 3:49 am
by Emral
as of Beta 4 Patch 3 hotfix, the onExitLevel event gets a level win type parameter passed, which you can then use to determine what to put into your SaveData. https://docs.codehaus.moe/#/constants/l ... l-win-type

Re: Any way to update a global save variable when beating level?

Posted: Tue Feb 09, 2021 3:13 pm
by dragon3025
Enjl wrote:
Tue Feb 09, 2021 3:49 am
as of Beta 4 Patch 3 hotfix, the onExitLevel event gets a level win type parameter passed, which you can then use to determine what to put into your SaveData. https://docs.codehaus.moe/#/constants/l ... l-win-type
Is that Handbook more up to date than this one?: https://docs.google.com/document/d/1uOd ... vPFaA/edit

How do I access that variable? I can see that I need

Code: Select all

function onExitLevel()
    if ??? == LEVEL_WIN_TYPE_OFFSCREEN then
        globalSave.variable = variable
    end
end
,but what do I replace ??? with?

Re: Any way to update a global save variable when beating level?

Posted: Tue Feb 09, 2021 3:22 pm
by Emral
Not documented yet cause whoever added it didn't document it...
function onExitLevel(winType)

Then you can use the winType variable.

Re: Any way to update a global save variable when beating level?

Posted: Tue Feb 09, 2021 3:28 pm
by dragon3025
Enjl wrote:
Tue Feb 09, 2021 3:22 pm
Not documented yet cause whoever added it didn't document it...
function onExitLevel(winType)

Then you can use the winType variable.
Thank you, it's working perfectly.