How do you make a custom npc die after a certain amount of frames?
Posted: Tue Dec 28, 2021 7:14 pm
by AlanLive2020
When i do it, all of the npcs with the same id die at the same time. Can anyone help?
Re: How do you make a custom npc die after a certain amount of frames?
Posted: Wed Dec 29, 2021 6:12 am
by deice
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.