• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ erro check slot item

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
Lua:
  Lua Script Error: [Spell Interface]
data/spells/scripts/attack/berserk.lua:onCastSpell
 data/spells/scripts/attack/berserk.lua:21: attempt to call method 'getSlotItem' (a nil value)
stack traceback:
 [C]: in function 'getSlotItem'
 data/spells/scripts/attack/berserk.lua:21: in function <data/spells/scripts/attack/berserk.lua:19>



Spells


Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.04) + 8) + (levelTotal)), -(((skillTotal * 0.09) + 13) + (levelTotal))}
end

local area = createCombatArea(AREA_SQUARE1X1)

local function getHighestSkillLevel(creature)
    local skillLevel = -1
    for skillType = SKILL_CLUB, SKILL_AXE do
        if skillLevel < creature:getEffectiveSkillLevel(skillType) then
            skillLevel = creature:getEffectiveSkillLevel(skillType)
        end
    end
    return skillLevel
end

function onCastSpell(creature, var)
 
  local weapon = creature:getSlotItem(CONST_SLOT_LEFT)
     if weapon then
    local dmg = ItemType(weapon.itemid):getAttack()
    local edmg = elementalDamage(weapon.itemid)
    local skill = getHighestSkillLevel(creature)
    local level = creature:getLevel()
    local result = Formula(skill, level, dmg + edmg)
    local position = creature:getPosition()
    if getConfigInfo("removeWeaponCharges") == true and weapon:hasAttribute("charges") then
    local charges = weapon:getAttribute("charges")
    if charges == 1 then
    weapon:remove(1)
    else
    weapon:setAttribute("charges", charges-1)
    end
    end

    if dmg > 0 then
    doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, position, area, math.min(0, result[1] * dmg / (edmg + dmg)), math.min(0, result[2] * dmg / (edmg+dmg)), CONST_ME_HITAREA)
    end
    if edmg > 0 then
    doAreaCombatHealth(creature, ItemType(weapon.itemid):getElementType(), position, area, math.min(0, result[1] * edmg / (edmg + dmg)), math.min(0, result[2] * edmg / (edmg+dmg)), CONST_ME_HITAREA)
    end
    end
 
    return true
end
 
Solution
otbr
Post automatically merged:

I found the error in case there is monster this spell as it is a monster it has no items there is a way to put it if it is a monster it does not execute
Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.04) + 8) + (levelTotal)), -(((skillTotal * 0.09) + 13) + (levelTotal))}
end

local area = createCombatArea(AREA_SQUARE1X1)

local function getHighestSkillLevel(creature)
    local skillLevel = -1
    for skillType = SKILL_CLUB, SKILL_AXE do
        if skillLevel < creature:getEffectiveSkillLevel(skillType) then
            skillLevel = creature:getEffectiveSkillLevel(skillType)
        end
    end
    return skillLevel
end...
What is the engine you use?
otbr
Post automatically merged:

I found the error in case there is monster this spell as it is a monster it has no items there is a way to put it if it is a monster it does not execute
 
Last edited:
otbr
Post automatically merged:

I found the error in case there is monster this spell as it is a monster it has no items there is a way to put it if it is a monster it does not execute
Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.04) + 8) + (levelTotal)), -(((skillTotal * 0.09) + 13) + (levelTotal))}
end

local area = createCombatArea(AREA_SQUARE1X1)

local function getHighestSkillLevel(creature)
    local skillLevel = -1
    for skillType = SKILL_CLUB, SKILL_AXE do
        if skillLevel < creature:getEffectiveSkillLevel(skillType) then
            skillLevel = creature:getEffectiveSkillLevel(skillType)
        end
    end
    return skillLevel
end

function onCastSpell(creature, var)
    if not creature:isPlayer() then
        return false
    end
    
    local weapon = creature:getSlotItem(CONST_SLOT_LEFT)
    if weapon then
        local dmg = ItemType(weapon.itemid):getAttack()
        local edmg = elementalDamage(weapon.itemid)
        local skill = getHighestSkillLevel(creature)
        local level = creature:getLevel()
        local result = Formula(skill, level, dmg + edmg)
        local position = creature:getPosition()
    
        if getConfigInfo("removeWeaponCharges") == true and weapon:hasAttribute("charges") then
            local charges = weapon:getAttribute("charges")
            if charges == 1 then
                weapon:remove(1)
            else
                weapon:setAttribute("charges", charges-1)
            end
        end

        if dmg > 0 then
            doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, position, area, math.min(0, result[1] * dmg / (edmg + dmg)), math.min(0, result[2] * dmg / (edmg+dmg)), CONST_ME_HITAREA)
        end
        if edmg > 0 then
            doAreaCombatHealth(creature, ItemType(weapon.itemid):getElementType(), position, area, math.min(0, result[1] * edmg / (edmg + dmg)), math.min(0, result[2] * edmg / (edmg+dmg)), CONST_ME_HITAREA)
        end
    end
 
    return true
end
 
Solution
  • Lua Script Error: [Spell Interface]
  • data/spells/scripts/attack/berserk.lua:eek:nCastSpell
  • cannot open config.lua: Too many open files
  • stack traceback:
  • [C]: at 0x555555666950
  • [C]: in function 'dofile'
  • data/lib/compat/compat.lua:1157: in function 'getConfigInfo'
  • data/spells/scripts/attack/berserk.lua:32: in function <data/spells/scripts/attack/berserk.lua:19>

Any idea?



compat.lua 1157
function getConfigInfo(info)
if type(info) ~= "string" then
return nil
end
dofile('config.lua')
return _G[info]
end


edit--

I removed the part that check in the config

if weapon:hasAttribute("charges") then
 
Last edited:
Back
Top