PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
origmsg = msg
msg = string.lower(msg)
if msgcontains(msg, 'heal') then
local healed = FALSE
if getCreatureHealth(cid) < 65 then
doCreatureAddHealth(cid,65-getCreatureHealth(cid))
doSendMagicEffect(getPlayerPosition(cid),CONST_ME_MAGIC_BLUE)
healed = TRUE
end
if hasCondition(cid, CONDITION_POISON) then
doRemoveCondition(cid, CONDITION_POISON)
doSendMagicEffect(getPlayerPosition(cid),CONST_ME_MAGIC_RED)
healed = TRUE
end
if healed == TRUE then
npcHandler:say("Let me heal your wounds!", cid)
else
npcHandler:say("You aren't looking so bad.", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
PHP:
data/npc/scripts/healer.lua:20: attempt to call global 'hasCondition' (a nil value)
stack traceback:
data/npc/scripts/healer.lua:20: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:374: in function 'onCreatureSay'
data/npc/scripts/healer.lua:7: in function <data/npc/scripts/healer.lua:7>