How do you make a custom npc die after a certain amount of frames?

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
AlanLive2020
Dolphin
Dolphin
Posts: 94
Joined: Fri Nov 27, 2020 8:15 am
Pronouns: he/him

How do you make a custom npc die after a certain amount of frames?

Postby AlanLive2020 » Tue Dec 28, 2021 7:14 pm

When i do it, all of the npcs with the same id die at the same time. Can anyone help?

deice
Buster Beetle
Buster Beetle
Posts: 441
Joined: Fri Jul 23, 2021 7:35 am

Re: How do you make a custom npc die after a certain amount of frames?

Postby deice » Wed Dec 29, 2021 6:12 am

if i'm understanding you correctly, you're trying to only make a specific instance of said npc die after a certain amount of frames elapse.
if you're not well-acquainted with custom npcs, i recommend looking at "npc-n.lua" in "data/_templates".

to accomplish what you've described, simply declare a local timer variable equal to the amount of frames, decrement it in onTickNPC() and call kill() when it reaches 0.


Return to “LunaLua Help”

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests