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

Lua Unknown problem with movements

Memerto

PHP, JS, LUA, HTML...
Joined
Oct 18, 2009
Messages
131
Solutions
6
Reaction score
25
Hi community!

I had a problem with a lua code and I don't know where is the mistake.. Here it is, I'll explain the trouble below:

Movement script called weapons.lua
Code:
condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, 28)

function onEquip(cid, item, slot)

   doAddCondition(cid, condition)
   
   return true
end

function onDeEquip(cid, item, slot)
   
     doRemoveCondition(cid, CONDITION_ATTRIBUTES, 1)

   return true
end

I wrote this in movements.xml
Code:
<movevent event="Equip" itemid="7382" function="onEquipItem" slot="hands" script="weapons.lua"/> 
<movevent event="DeEquip" itemid="7382" function="onDeEquipItem" slot="hands" script="weapons.lua"/>

I was trying to make equip items to raise skills using movements instead of items.xml keys and I thought it'd be easy , but I failed. It's supossed to be a sword that increase your sword skill by 28, but it has no effect when I equip it. No errors in console. I'm using tfs 0.3.6 pl1.

So here I am, asking you, wise community: where's the error?
 
nvm, i didnt read well enough

try some other conditions, such as manashield, or invis, or whatever to see if the condition might have something wrong

otherwise, i think you can set bonus skills on items in movements.xml as attributes, cant you?

Code:
<attribute key="skillSword" value="4" />
from my 0.3.6 items.xml
 
Last edited:
Yep, actually I can do it in items.xml, but I'm trying to make a movement script for this, so I can get a dinamic skill increase, and not the static one items.xml offers to me ;) .

I tried what you said with invis:

Code:
local condition = createConditionObject(CONDITION_INVISIBLE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 200000)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)

function onEquip(cid, item, slot)

   doAddCondition(cid, condition)
   
   return true
end

function onDeEquip(cid, item, slot)
   
     doRemoveCondition(cid, CONDITION_INVISIBLE, 1)

   return true
end

Didn't work, but thx for the idea!
 
I think your movements.xml may be the issue.
Here is how I set-up mine when I was doing custom scripts for some of the stuff.
Code:
<movevent type="Equip" level="1" itemid="2463" slot="armor" event="script" value="armor.lua"/>
<movevent type="DeEquip" level="1" itemid="2463" slot="armor" event="script" value="armor.lua"/>

Also, if you want to preserve most/all of the item.xml properties, you need to use
Code:
return callFunction(cid, item.uid, slot, boolean)
Instead of return true.

I also suggest adding a couple print's into the code as well, just to ensure they are actually loading.
Code:
print(1)

report back with your updated scripts and testing results if possible.
 
Thx Xikini for the answer!

I made the changes you suggested to the scripts:

Code:
<movevent type="Equip" level="1" itemid="7382" slot="hands" event="script" value="weapons.lua"/>
<movevent type="DeEquip" level="1" itemid="7382" slot="hands" event="script" value="weapons.lua"/>

Code:
local condition = createConditionObject(CONDITION_INVISIBLE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 200000)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)

function onEquip(cid, item, slot)

   doAddCondition(cid, condition)
   print(12)
   
   return callFunction(cid, item.uid, slot, boolean)
end

function onDeEquip(cid, item, slot)
   
     doRemoveCondition(cid, CONDITION_INVISIBLE, 1)
     print(13)

   return callFunction(cid, item.uid, slot, boolean)
end

Nothing happened, and nothing printed in console.

When I was doing this i tried to put hand instead of hands in the slot in movements.xml. When I tried to equip the item with this little change, the condition worked fine, but there was an error and I could't put the item in the slot. It was really weird when I saw the invisible character who can't equip the item. I got an error in console with this little change too, and the prints worked this time:

Code:
[Error - MoveEvents Interface]
data/movements/scripts/weapons.lua:onEquip
Description:
data/movements/scripts/weapons.lua:12:attempt to call global 'callFunction' (a nil value)
stack traceback:
                  data/movements/scripts/weapons.lua:12: in function (data/movements/scripts/weapons.lua:7)
12
 
Code:
[Error - MoveEvents Interface]
data/movements/scripts/weapons.lua:onEquip
Description:
data/movements/scripts/weapons.lua:12:attempt to call global 'callFunction' (a nil value)
stack traceback:
                  data/movements/scripts/weapons.lua:12: in function (data/movements/scripts/weapons.lua:7)
12
Like Xeraphus mentioned very briefly, it seems your distribution doesn't have the callFunction, function.

Change those lines back to return true, and it should be able to equip for you, while using the correct movements.xml lines.
 
Back
Top