Respawn in Big State

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

Moderator: Userbase Moderators

Muffler
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 20, 2021 12:42 pm
Pronouns: he/him

Respawn in Big State

Postby Muffler » Tue Feb 18, 2025 1:00 pm

Hello! I'm looking for a way to respawn the player in Big state (player.powerup == 2) after dying. I managed to make the player be big when spawning in a level using this:

Code: Select all

function onStart()
	if player.powerup < 2 then
		player.powerup = 2
	end
end
The problem is that it will always make you become big when starting a level, even if you were small before, while I wanted to do that only when the player respawns after a death. Just like how it is in SM3DL and SM3DW. Can anyone help me? Thanks in advance.

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 607
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: Respawn in Big State

Postby mariobrigade2018 » Tue Feb 18, 2025 1:10 pm

Something like this?
viewtopic.php?t=23742&start=320#p384173
MrDoubleA, in the Lunalua general help section, wrote:

Code: Select all

SaveData.startedEpisode = SaveData.startedEpisode or false

function onStart()
    if not SaveData.startedEpisode then
        for _,p in ipairs(Player.get()) do
            p.powerup = PLAYER_BIG
        end
        
        SaveData.startedEpisode = true
    end
end

function onExitLevel(exitType)
    if exitType == 0 then
        -- Is everybody dead?
        local allDead = true
        
        for _,p in ipairs(Player.get()) do
            if not p:mem(0x13C,FIELD_BOOL) then -- not dead
                allDead = false
                break
            end
        end
        
        if allDead then
            -- Make everybody big
            for _,p in ipairs(Player.get()) do
                p.powerup = PLAYER_BIG
            end
        end
    end
end

Muffler
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 20, 2021 12:42 pm
Pronouns: he/him

Re: Respawn in Big State

Postby Muffler » Tue Feb 18, 2025 1:48 pm

mariobrigade2018 wrote:
Tue Feb 18, 2025 1:10 pm
Something like this?
viewtopic.php?t=23742&start=320#p384173
MrDoubleA, in the Lunalua general help section, wrote:

Code: Select all

SaveData.startedEpisode = SaveData.startedEpisode or false

function onStart()
    if not SaveData.startedEpisode then
        for _,p in ipairs(Player.get()) do
            p.powerup = PLAYER_BIG
        end
        
        SaveData.startedEpisode = true
    end
end

function onExitLevel(exitType)
    if exitType == 0 then
        -- Is everybody dead?
        local allDead = true
        
        for _,p in ipairs(Player.get()) do
            if not p:mem(0x13C,FIELD_BOOL) then -- not dead
                allDead = false
                break
            end
        end
        
        if allDead then
            -- Make everybody big
            for _,p in ipairs(Player.get()) do
                p.powerup = PLAYER_BIG
            end
        end
    end
end
It works flawlessly, thank you so much!


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 4 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari