• 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!

in function 'addCondition'

olekpro

Member
Joined
Nov 1, 2014
Messages
121
Reaction score
6
Lua:
data/spells/scripts/monster/renegade knight.lua:9: attempt to call method 'addCondition' (a nil value)
stack traceback:
        [C]: in function 'addCondition'
        data/spells/scripts/monster/renegade knight.lua:9: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/monster/renegade knight.lua

how to fix? TFS 1.2
renegade knight.lua :

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 6)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

local condition = Condition(COMBAT_PHYSICALDAMAGE)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(3, 10000, -25)
combat:addCondition(condition)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
 
Solution
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))


local bleeding = Condition(CONDITION_BLEEDING)
bleeding:setParameter(CONDITION_PARAM_DELAYED, true)
bleeding:addDamage(3, 10000, -25)
combat:setCondition(bleeding)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
Maybe your engine isn't updated to use
Lua:
combat:addCondition(condition)
replace it with
Lua:
combat:setCondition(condition)
and retry or replace your data\lib\compat\compat.lua with this one

Now i got full consol of errors:
Lua:
Lua Script Error: [Test Interface]
data/spells/scripts/support/swift_foot.lua
data/lib/compat/compat.lua:120: attempt to call field 'addCondition' (a nil value)
stack traceback:
        [C]: in function 'addCondition'
        data/lib/compat/compat.lua:120: in function 'setCondition'
        data/spells/scripts/support/swift_foot.lua:8: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/support/swift_foot.lua

other spells now are retarded.
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))


local bleeding = Condition(CONDITION_BLEEDING)
bleeding:setParameter(CONDITION_PARAM_DELAYED, true)
bleeding:addDamage(3, 10000, -25)
combat:setCondition(bleeding)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
 
Solution
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_SQUARE1X1))


local bleeding = Condition(CONDITION_BLEEDING)
bleeding:setParameter(CONDITION_PARAM_DELAYED, true)
bleeding:addDamage(3, 10000, -25)
combat:setCondition(bleeding)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
thanks, cheers
 
Now i got full consol of errors:
Lua:
Lua Script Error: [Test Interface]
data/spells/scripts/support/swift_foot.lua
data/lib/compat/compat.lua:120: attempt to call field 'addCondition' (a nil value)
stack traceback:
        [C]: in function 'addCondition'
        data/lib/compat/compat.lua:120: in function 'setCondition'
        data/spells/scripts/support/swift_foot.lua:8: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/support/swift_foot.lua

other spells now are retarded.
Yes that's what happens when you read 50% of the solution.
 
Yes that's what happens when you read 50% of the solution.

Or the compat.lua was fine and you missed something else?

Lua:
local condition = Condition(COMBAT_PHYSICALDAMAGE)

COMBAT_PHYSICALDAMAGE is not condition.
CONDITION_BLEEDING is condition for PHYSICALDAMAGE

Sorry. 🥺
 
Still if you/he did read the first part instead of ignoring it which I point to try setCondition instead of
addCondition then it would return different error and I would have had a second look on what I missed while reading quick.
 
Yes that's what happens when you read 50% of the solution.
i change compat.lua for that what u said and i got errors. that's why i decided to reback my compat and tried @Lessaire script and that worked without errors (im not good in scripting enought yet) but cheers for helping me guys.
Post automatically merged:

@@update new problem



Lua Script Error: [Spell Interface]
data/spells/scripts/monster/silencer_skill_reducer.lua:eek:nCastSpell
data/spells/scripts/monster/silencer_skill_reducer.lua:14: attempt to call method 'getTargets' (a nil value)
stack traceback:
[C]: in function 'getTargets'
data/spells/scripts/monster/silencer_skill_reducer.lua:14: in function <data/spells/scripts/monster/silencer_skill_reducer.lua:11>




Lua Script Error: [Spell Interface]
data/spells/scripts/monster/shock_head_skill_reducer_1.lua:eek:nCastSpell
data/spells/scripts/monster/shock_head_skill_reducer_1.lua:12: attempt to call method 'getTargets' (a nil value)
stack traceback:
[C]: in function 'getTargets'
data/spells/scripts/monster/shock_head_skill_reducer_1.lua:12: in function <data/spells/scripts/monster/shock_head_skill_reducer_1.lua:11>



Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))

local parameters = {
    {key = CONDITION_PARAM_TICKS, value = 6 * 1000},
    {key = CONDITION_PARAM_SKILL_SHIELDPERCENT, value = 65}
}

function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        target:addAttributeCondition(parameters)
    end
    return true
end
 
Last edited:
Back
Top