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

Item that spreads light

tokenzz

:thinking:
Joined
Feb 2, 2013
Messages
779
Solutions
2
Reaction score
346
Hiho,

I've got a question why the following code doesn't work. Might be an issue related to what I've typed in movements.xml.

Source: OTServ 0.6.3 (similar to OTHire)

Code:
local light = createConditionObject(CONDITION_LIGHT)
setConditionParam(light, CONDITION_PARAM_LIGHT_LEVEL, 10)
setConditionParam(light, CONDITION_PARAM_LIGHT_COLOR, 215)

function onEquip(cid, item, slot)
if (item.id == 2642) then
doAddCondition(cid, light)
return false
end
end

what should I write in movements.xml + what am I missing?

Kind regards,

t0kenz

NOTE: Doesn't give me an error in the console.
 
Last edited:
Code:
CONDITION_PARAM_TICKS
Using 1.2 code as an example
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 8)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, (11 * 60 + 35) * 1000)
combat:setCondition(condition)

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
In this case combat is just to execute the special effects, where as condition is used to apply the expected result.
 
Code:
CONDITION_PARAM_TICKS
Is that required, or can I simply ignore it? The item is meant to have no time limit. Or should I to make it infinite just specify a ridiculously high number?
 
Code:
setConditionParam(light, CONDITION_PARAM_TICKS, -1) -- infinite time
Ty. Is the rest fine?

I believe my movevent is the issue i'm having.

Code:
    <movevent event="Equip" itemid="2642" slot="feet" function="onEquipItem" />
 <movevent event="DeEquip" itemid="2642" slot="feet" function="onDeEquipItem" />
 
Code:
local light = createConditionObject(CONDITION_LIGHT)
setConditionParam(light, CONDITION_PARAM_LIGHT_LEVEL, 10)
setConditionParam(light, CONDITION_PARAM_LIGHT_COLOR, 215)
setConditionParam(light, CONDITION_PARAM_TICKS, -1)

function onEquip(cid, item, slot)
    if (item.itemid == 2642) then
        doAddCondition(cid, light)
        return true
    end
end
 
Code:
local light = createConditionObject(CONDITION_LIGHT)
setConditionParam(light, CONDITION_PARAM_LIGHT_LEVEL, 10)
setConditionParam(light, CONDITION_PARAM_LIGHT_COLOR, 215)
setConditionParam(light, CONDITION_PARAM_TICKS, -1)

function onEquip(cid, item, slot)
    if (item.itemid == 2642) then
        doAddCondition(cid, light)
        return true
    end
end

Should the movevent.xml events work?
 
lightboots.lua
Code:
local light = createConditionObject(CONDITION_LIGHT)
setConditionParam(light, CONDITION_PARAM_LIGHT_LEVEL, 10)
setConditionParam(light, CONDITION_PARAM_LIGHT_COLOR, 215)
setConditionParam(light, CONDITION_PARAM_TICKS, -1)

function onEquip(cid, item, slot)
    if (item.itemid == 2642) then
        doAddCondition(cid, light)
        return true
    end
end

function onDeEquip(cid, item, slot)
    if (item.itemid == 2642) then
        if hasCondition(cid, CONDITION_LIGHT) then
             doRemoveCondition(cid, light)
        end
    end
    return true
end
Code:
<movevent event="Equip" itemid="2642" slot="feet" script="lightboots.lua" />
<movevent event="DeEquip" itemid="2642" slot="feet" script="lightboots.lua" />
 
lightboots.lua
Code:
local light = createConditionObject(CONDITION_LIGHT)
setConditionParam(light, CONDITION_PARAM_LIGHT_LEVEL, 10)
setConditionParam(light, CONDITION_PARAM_LIGHT_COLOR, 215)
setConditionParam(light, CONDITION_PARAM_TICKS, -1)

function onEquip(cid, item, slot)
    if (item.itemid == 2642) then
        doAddCondition(cid, light)
        return true
    end
end

function onDeEquip(cid, item, slot)
    if (item.itemid == 2642) then
        if hasCondition(cid, CONDITION_LIGHT) then
             doRemoveCondition(cid, light)
        end
    end
    return true
end
Code:
<movevent event="Equip" itemid="2642" slot="feet" script="lightboots.lua" />
<movevent event="DeEquip" itemid="2642" slot="feet" script="lightboots.lua" />


Thank you :)

-- Solved, feel free to close!
 
Just one issue. When I deequip the item, the condition state isn't removed. Tried fixing it myself but without any luck
 
Just one issue. When I deequip the item, the condition state isn't removed. Tried fixing it myself but without any luck
change this
Code:
 doRemoveCondition(cid, light)
to
Code:
doRemoveCondition(cid, CONDITION_LIGHT)
My bad, I am guessing most of the time when i write this stuff, but that should work :p
 
change this
Code:
 doRemoveCondition(cid, light)
to
Code:
doRemoveCondition(cid, CONDITION_LIGHT)
My bad, I am guessing most of the time when i write this stuff, but that should work :p
yeah finally figured it out, but thanks for answering anyhow. Might solve the issue for others reading this topic.
 
Back
Top