Hello im editing my potion.lua this function was not working or causing nothing now when i want to fill a pot with a fluid from the floor or from a potion, get this error in console
can somebody tell me how to edit the script to make fluids fills pot?
this is part of the script tell me if you need the full version
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/Other/fluids/potions.lua:onUse
data/actions/scripts/Other/fluids/potions.lua:211: attempt to index local 'potion' (a nil value)
stack traceback:
data/actions/scripts/Other/fluids/potions.lua:211: in function <data/actions/scripts/Other/fluids/potions.lua:196>
can somebody tell me how to edit the script to make fluids fills pot?
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local potion = potions[item:getId()]
local tile = Tile(toPosition)
local items = tile:getItems()
if items then
for i, item in ipairs(items) do
local targetItemType = ItemType(item:getId())
if targetItemType and targetItemType:getType() == ITEM_TYPE_TELEPORT then
return false
end
end
end
if type(target) == "userdata" and not target:isPlayer() then
if potion.health and potion.mana then
Game.createItem(2025, 35, toPosition)
elseif potion.health then
Game.createItem(2025, 10, toPosition)
elseif potion.mana then
Game.createItem(2025, 7, toPosition)
end
if configManager.getBoolean(configKeys.REMOVE_POTION_CHARGES) then
item:remove(1)
if potion.flask and potion.flask > 0 then
player:addItem(potion.flask)
end
end
return true
end
if not player:getGroup():getAccess() and (potion.level and player:getLevel() < potion.level or potion.vocations and not table.contains(potion.vocations, player:getVocation():getId())) then
player:say(potion.description, TALKTYPE_POTION)
return true
end
if potion.condition then
if potion.capacity then
potion.capacity(player)
end
player:addCondition(potion.condition)
player:say(potion.text, TALKTYPE_POTION)
player:getPosition():sendMagicEffect(potion.effect)
elseif potion.transform then
local reward = potion.transform[math.random(#potion.transform)]
if fromPosition.x == CONTAINER_POSITION then
local targetContainer = Container(item:getParent().uid)
targetContainer:addItem(reward, 1)
else
Game.createItem(reward, 1, fromPosition)
end
item:getPosition():sendMagicEffect(potion.effect)
item:remove(1)
return true
else
if potion.health then
doTargetCombat(player, target, COMBAT_HEALING, potion.health[1], potion.health[2])
end
if potion.mana then
doTargetCombat(player, target, COMBAT_MANADRAIN, potion.mana[1], potion.mana[2])
end
if potion.antidote then
target:removeCondition(CONDITION_POISON)
end
player:addAchievementProgress("Potion Addict", 100000)
player:addItem(potion.flask)
target:say("Aaaah...", TALKTYPE_POTION)
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if not configManager.getBoolean(configKeys.REMOVE_POTION_CHARGES) then
return true
end
item:remove(1)
return true
end
this is part of the script tell me if you need the full version