Page 1 of 1

Respawn in Big State

Posted: Tue Feb 18, 2025 1:00 pm
by Muffler
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.

Re: Respawn in Big State

Posted: Tue Feb 18, 2025 1:10 pm
by mariobrigade2018
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

Re: Respawn in Big State

Posted: Tue Feb 18, 2025 1:48 pm
by Muffler
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!