Quantcast
Channel: Super Mario Bros. X Forums
Viewing all articles
Browse latest Browse all 2647

LunaLua Help • Re: "No event onNPCHarm was found!"

$
0
0

Code:

local damage = 1local jumpInterval = 10--Register eventsfunction sampleNPC.onInitAPI()npcManager.registerEvent(npcID, sampleNPC, "onNPCHarm")npcManager.registerEvent(npcID, sampleNPC, "onTickEndNPC")npcManager.registerEvent(npcID, sampleNPC, "onNPCKill")endfunction sampleNPC.onNPCHarm(eventObj, npc, harmReason, culprit)if harmReason == HARM_TYPE_NPC thendamage = damage + 1endend

onNPCHarm and onNPCKill cannot be registered by npcManager, you need to use registerEvent and an id check to make them work.

Code:

function sampleNPC.onInitAPI()registerEvent(sampleNPC, "onNPCHarm")registerEvent(sampleNPC, "onNPCKill")npcManager.registerEvent(npcID, sampleNPC, "onTickEndNPC")endfunction sampleNPC.onNPCHarm(eventObj, npc, harmReason, culprit)-- don't run for other npcsif npc.id ~= npcID then return end-- do stuff hereend

Statistics: Posted by Marioman2007 — Sat Sep 14, 2024 1:44 am



Viewing all articles
Browse latest Browse all 2647

Trending Articles