My Antidote Potion cures poison, but don't add an empty potion when used:
This is the console error:
Lua:
local EMPTY_POTION = 7636
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_POISON)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenExActions'))
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(not isPlayer(itemEx.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if(not doCombat(cid, combat, numberToVariant(itemEx.uid))) then
return false
end
doAddCondition(cid, exhaust)
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
if(fromPosition ~= CONTAINER_POSITION) then
doCreateItem(potion.empty, fromPosition)
else
doPlayerAddItem(cid, potion.empty, 1)
end
return true
end
This is the console error:
Code:
antidote_potion.lua:31: attemptto index global 'potion' <a nil value>