How to reset Checkpoint progress when getting a Game Over?

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
Bnhea
Goomba
Goomba
Posts: 1
Joined: Thu Jan 04, 2024 4:32 pm
Pronouns: He/Him

How to reset Checkpoint progress when getting a Game Over?

Postby Bnhea » Thu Jan 04, 2024 4:42 pm

When you lose all your lives, nothing actually happens to your progress.

I am not a coder, so I thought I'd ask on here. Is there anything I can do to reset checkpoint progress when a player loses all their lives? Like how it works in actual Mario games?

I know it's not for everyone but I think there is some charm in having it, especially in more old-school styled projects.

Just_Thomas
Snifit
Snifit
Posts: 232
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: How to reset Checkpoint progress when getting a Game Over?

Postby Just_Thomas » Sun Jan 21, 2024 7:35 am

Sorry if my post does not provide any help, but I am also VERY interested in this topic.

Looking on codehaus I only found "Level victory constants" and "Level (Levels)" which also only seems to deal with winning of a level.

Does somebody know if there is some kind of "gameover behaviour"? (I would have expected to see or find something like that under "defines")
I mean, restart at least checkpoint if maybe a nice option for those who need it but I also miss something like "return to menu" or at least "restart level when no more lifes left".

The World Settings are a little bit of a scam, as "Restart last level after death" will be overwritten by a checkpoint or rather the last one.

Anyway, with the current settings the player does absolutely not get punished for a gameover, when all lifes are gone.

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

Re: How to reset Checkpoint progress when getting a Game Over?

Postby Emral » Sun Jan 21, 2024 8:53 am

smbx2 has no concept of gameovers. it just unloads the episode when all lives are lost

checkpoint data is saved to GameData which only persists in a session. it persisting through the title screen is a bug... in the buggy title screen (sidenote: NEVER load into another episode from it because it can actually wipe your save and the title screen will be removed in a future version of smbx2)

you can reset gamedata by just using the line GameData = {} in onExitLevel when all lives are lost.
or just call Misc.exitEngine() which ends the process and clears GameData by proxy while avoiding the title screen.
OR you can ALSO write your own Game Over sequence that resets lives and gamedata before reloading the map. the simplest implementation is just resetting mem(0x00B2C5AC,FIELD_FLOAT, 3) in onExitLevel when all lives are lost, calling Level.exit() and clearing GameData like above.
Just_Thomas wrote:
Sun Jan 21, 2024 7:35 am
The World Settings are a little bit of a scam, as "Restart last level after death" will be overwritten by a checkpoint or rather the last one.
all "restart last level after death" does is causing a death to load the current level rather than the map. it's functionally identical to skipping the part where you mash jump on the map to get back into the level as fast as possible. disregarding the bug that autostart events dont run if the flag is enabled.

punishing the player sucks so i hope you don't go too hard on them

Just_Thomas
Snifit
Snifit
Posts: 232
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: How to reset Checkpoint progress when getting a Game Over?

Postby Just_Thomas » Sun Jan 21, 2024 9:47 am

Emral wrote:
Sun Jan 21, 2024 8:53 am
smbx2 has no concept of gameovers. it just unloads the episode when all lives are lost

checkpoint data is saved to GameData which only persists in a session. it persisting through the title screen is a bug... in the buggy title screen (sidenote: NEVER load into another episode from it because it can actually wipe your save and the title screen will be removed in a future version of smbx2)

you can reset gamedata by just using the line GameData = {} in onExitLevel when all lives are lost.
or just call Misc.exitEngine() which ends the process and clears GameData by proxy while avoiding the title screen.
OR you can ALSO write your own Game Over sequence that resets lives and gamedata before reloading the map. the simplest implementation is just resetting mem(0x00B2C5AC,FIELD_FLOAT, 3) in onExitLevel when all lives are lost, calling Level.exit() and clearing GameData like above.
Just_Thomas wrote:
Sun Jan 21, 2024 7:35 am
The World Settings are a little bit of a scam, as "Restart last level after death" will be overwritten by a checkpoint or rather the last one.
all "restart last level after death" does is causing a death to load the current level rather than the map. it's functionally identical to skipping the part where you mash jump on the map to get back into the level as fast as possible. disregarding the bug that autostart events dont run if the flag is enabled.

punishing the player sucks so i hope you don't go too hard on them
I did not intend to visit each player then in front of their pc/mac/laptop and using a whip.

Well, this explains a lot, somehow.

Code: Select all

function onExitLevel()
	resetting mem(0x00B2C5AC,FIELD_FLOAT, 3)
end
SMBX wants a "=" there?

Image

Edit: I think I was not supposed to put the word "resetting" in there .. I am trying again

Edit 2: My life counter does not go down anymore now with that. Uhmmmmmmm ....................................

Edit 3:
Ok, this stuff gets weirder if I actually do that

Code: Select all

function onExitLevel()
	mem(0x00B2C5AC,FIELD_FLOAT, 3)
	Level.exit()
end
in level01 I got a 1up so I finished level01 with 4 instead of the 3 (starter/extra) lifes.
Got in level02 .. life counter shows 3 instead and I ... have unlimited lives again. This really is messed up.

Would this even work in theory now?

if player is in level01 and extra lifes < 0 then clear checkpoint, reset extra lifes to 3 again, restart from level01
if player is in level02 and extra lifes < 0 then (clear checkpoint?), reset extra lifes to 3 again, restart from level01

But from what I understood this is not really something which can be changed from luna. Hmm.

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

Re: How to reset Checkpoint progress when getting a Game Over?

Postby Emral » Sun Jan 21, 2024 6:22 pm

you seem to have missed the "when all lives are lost" part
so that'd translate to a "if player.deathTimer > 0 and mem(0x00B2C5AC,FIELD_FLOAT) == 0 then" check around the resetting block of code
since there are no checks, currently you end up with a constant 3 lives if you reset lives to 3 every time you exit a level for any reason. that's the lua you wrote there

Just_Thomas
Snifit
Snifit
Posts: 232
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: How to reset Checkpoint progress when getting a Game Over?

Postby Just_Thomas » Mon Jan 22, 2024 9:08 am

Bnhea wrote:
Thu Jan 04, 2024 4:42 pm
When you lose all your lives, nothing actually happens to your progress.

I am not a coder, so I thought I'd ask on here. Is there anything I can do to reset checkpoint progress when a player loses all their lives? Like how it works in actual Mario games?

I know it's not for everyone but I think there is some charm in having it, especially in more old-school styled projects.
This combination seems to works...
In my case it is the project luna lua file.

Code: Select all

function onExitLevel()
	if player.deathTimer > 0 and mem(0x00B2C5AC,FIELD_FLOAT) == 0 then
	GameData = {}
	end
end
Emral wrote:
Sun Jan 21, 2024 6:22 pm
you seem to have missed the "when all lives are lost" part
so that'd translate to a "if player.deathTimer > 0 and mem(0x00B2C5AC,FIELD_FLOAT) == 0 then" check around the resetting block of code
since there are no checks, currently you end up with a constant 3 lives if you reset lives to 3 every time you exit a level for any reason. that's the lua you wrote there
Yes, it is as you said. Thanks.


Return to “LunaLua Help”

Who is online

Users browsing this forum: Alexx0612 and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari