Can SaveData replace pnpc?

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
Wooliestplate89
Koopa
Koopa
Posts: 17
Joined: Sun Aug 15, 2021 12:25 am
Flair: Red sus, oh wait i'm red...
Pronouns: he/him
Contact:

Can SaveData replace pnpc?

Postby Wooliestplate89 » Sun Sep 04, 2022 2:03 am

I want to save a variable to a goomba npc but pnpc is deprecated, I think I can use SaveData to do this instead, but I'm not sure how to do it.

Here is my code:

Code: Select all

local goombajumpTimer = 0

function onTick()
    goombajumpTimer = goombajumpTimer + 1
    if goombajumpTimer > 80 then
        goombajumpTimer = 0
    end
    local goombas = NPC.get(1, player.section)
    for index,npc in ipairs(goombas) do
        if goombajumpTimer == 0 then
            npc.speedY = -10
        end
    end
end

Yes I am following Enjl's Luna Lua tutorial because I'm new to Luna lua,

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

Re: Can SaveData replace pnpc?

Postby Emral » Sun Sep 04, 2022 2:26 am

SaveData is for persistent storage across runs. pnpc is replaced by the data table.
https://www.youtube.com/watch?v=A3qBcwecmXk

for example you can have a npc.data.goombaJumpTimer and do the logic for the variable within the for loop

Wooliestplate89
Koopa
Koopa
Posts: 17
Joined: Sun Aug 15, 2021 12:25 am
Flair: Red sus, oh wait i'm red...
Pronouns: he/him
Contact:

Re: Can SaveData replace pnpc?

Postby Wooliestplate89 » Sun Sep 04, 2022 3:15 am

I just found out on the pge wiki that you can now access npc.data, npc.uid, npc.pid, and npc.pidIsDirty without pnpc, which is why pnpc is deprecated. I understand now.

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

Re: Can SaveData replace pnpc?

Postby Emral » Sun Sep 04, 2022 3:19 am

Wooliestplate89 wrote:
Sun Sep 04, 2022 3:15 am
I just found out on the pge wiki that you can now access npc.data, npc.uid, npc.pid, and npc.pidIsDirty without pnpc, which is why pnpc is deprecated. I understand now.
PGE wiki hasn't been maintained in a long time. SMBX2 documentation contains more information.
https://docs.codehaus.moe/#/concepts/data-table

Wooliestplate89
Koopa
Koopa
Posts: 17
Joined: Sun Aug 15, 2021 12:25 am
Flair: Red sus, oh wait i'm red...
Pronouns: he/him
Contact:

Re: Can SaveData replace pnpc?

Postby Wooliestplate89 » Sun Sep 04, 2022 9:14 am

Oooh thanks for telling me :D.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari