pasiak12
Well-Known Member
- Joined
- Jun 7, 2009
- Messages
- 261
- Solutions
- 13
- Reaction score
- 71
I would like to replace stealth ring with new item called 'mana ring'.
I have edited items.xml
And now I would like to execute custom script when someone is wearing the ring.
The original part of movements.xml is:
I would like to put somewhere script="manaring.lua" but every combination I tried didn't work correctly.
The manaring.lua script should add 1% mana pers sec to the user.
The script hasn't been tested yet
I don't know if the script has been projected properly yet. I think some kind of 'addEvent' function with time interval would be better, can anyone also give me a tip to that?
tfs 1.2
I have edited items.xml
Code:
<item id="2202" article="a" name="mana ring (1% max mana / sec)">
<attribute key="weight" value="100" />
<attribute key="slotType" value="ring" />
<attribute key="transformDeEquipTo" value="2165" />
</item>
<item id="2165" article="a" name="mana ring">
<attribute key="weight" value="100" />
<attribute key="slotType" value="ring" />
<attribute key="transformEquipTo" value="2202" />
</item>
And now I would like to execute custom script when someone is wearing the ring.
The original part of movements.xml is:
Code:
<!-- MANA RING -->
<movevent event="Equip" itemid="2165" slot="ring" function="onEquipItem" />
<movevent event="Equip" itemid="2202" slot="ring" function="onEquipItem" />
<movevent event="DeEquip" itemid="2202" slot="ring" function="onDeEquipItem" />
I would like to put somewhere script="manaring.lua" but every combination I tried didn't work correctly.
The manaring.lua script should add 1% mana pers sec to the user.
The script hasn't been tested yet
Code:
function onEquip(creature, item, slot)
local player = creature:getPlayer()
local ring = player:getSlotItem(CONST_SLOT_RING)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "ring on") --debug
if item.itemid == 2202 and slot == 9 then
creature:getPlayer():sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "condition is met") --debug
--some loop ?
mana1 = creature:getMaxMana() * 1/100 -- get 1% max mana
creature:addMana(mana1)
--some 'wait' method 1 sec
end
end
I don't know if the script has been projected properly yet. I think some kind of 'addEvent' function with time interval would be better, can anyone also give me a tip to that?
tfs 1.2