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

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

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

Postby dragon3025 » Mon Feb 08, 2021 8:56 pm

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?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

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

Postby Emral » 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

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

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

Postby dragon3025 » Tue Feb 09, 2021 3:13 pm

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?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

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

Postby Emral » 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.

dragon3025
Bot
Bot
Posts: 55
Joined: Fri Aug 07, 2015 5:02 pm

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

Postby dragon3025 » Tue Feb 09, 2021 3:28 pm

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.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari