MoveEvent
There are many types of events for the MoveEvent interface, here is a list.
  • [onStepIn(creature, item, pos, fromPosition)]
  • [onStepOut(creature, item, pos, fromPosition)]
  • [onEquip(player, item, slot, isCheck)]
  • [onDeEquip(player, item, slot, isCheck)]
  • [onAddItem(moveitem, tileitem, pos)]
  • [onRemoveItem(moveitem, tileitem, pos)]
  1. 1.
    You can create a MoveEvent script in data/movements/scripts folder, but
  2. 2.
    You must register MoveEvents in data/movements/movements.xml, here is an example
1
<movevent event="StepIn" itemid="293" script="decay.lua" />
Copied!
  1. 1.
    Alternatively you can use revscript method to register via lua, by saving a .lua file in data/scripts folder.
Please keep in mind you can name your script whatever you want as long as it ends in .lua, and its full name is in the xml, with script=""

onStepIn(creature, item, pos, fromPosition)

  • creature -- 1st arg/parameter /userdata/ = The creature who is doing the stepin movement
  • item -- 2nd arg/parameter /userdata/ = The item that is being stepped on.
  • pos -- 3rd arg/parameter /userdata/ = The position for the location being stepped on
  • fromPosition -- 4th arg/parameter /userdata/ = The position which the creature moved from
onStepin is called whenever any creature steps on the registered item id(s)
You can register your event in movement.xml like so:
1
<movevent event="StepIn" fromid="11165" toid="11188" script="mud.lua" />
Copied!
You can then call the event in a script like so:
mud.lua
1
local combat = Combat()
2
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
3
4
local condition = Condition(CONDITION_PARALYZE)
5
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
6
condition:setFormula(-1, 80, -1, 80)
7
combat:addCondition(condition)
8
9
function onStepIn(creature, item, pos, fromPosition)
10
if not creature:hasCondition(CONDITION_PARALYZE) then
11
combat:execute(creature, Variant(creature))
12
end
13
return true
14
end
Copied!
Always remember to return true if you wish to allow creature to step there, returning false or not returning true will block creature from stepping there!

onStepOut(creature, item, pos, fromPosition)

  • creature -- 1st arg/parameter /userdata/ = The creature who is doing the stepin movement
  • item -- 2nd arg/parameter /userdata/ = The item that is being stepped on.
  • pos -- 3rd arg/parameter /userdata/ = The position for the location being stepped on
  • fromPosition -- 4th arg/parameter /userdata/ = The position which the creature moved from
onStepOut is called whenever any player tries to step off registered item id(s)
You can register your event in creaturescripts.xml like so:
1
<movevent event="StepOut" fromid="11165" toid="11188" script="mud.lua" />
Copied!
You can then call the event in a script like so:
mud.lua
1
local mudIds = {11165, 11166, 11167, 11168, 11169, 11170, 11171, 11172, 11173, 11174, 11175, 11176, 11178, 11179, 11180, 11181, 11182, 11183, 11184, 11185, 11186, 11187, 11188}
2
3
function onStepOut(creature, item, pos, fromPosition)
4
for i = 1, #mudIds do
5
if Tile(fromPosition):getItemById(mudIds[i]) then
6
pos:sendDistanceEffect(fromPosition, CONST_ANI_SMALLEARTH, creature)
7
end
8
end
9
return true
10
end
Copied!
Always remember to return true if you wish to allow creature to step off the tile they are on, returning false or not returning true will block the creature from being able to step off!

onEquip(player, item, slot, isCheck)

  • player -- 1st arg/parameter /userdata/ = The player who is equipping the item
  • item -- 2nd arg/parameter /userdata/ = The item that is being equipped
  • slot -- 3rd arg/parameter /integer/ = The slot item is being equipped to, represents a const value.
  • isCheck -- 4th arg/parameter /boolean/ = is this before item is equipped, true or false
onEquip runs twice everytime a player equips an item. It runs once before it is equipped, and runs again after. The parameter "isCheck" is true value the first time, before the item is equipped, and false the second time, after it is equipped. This is kind of unique to consider as it is one item with one registered event that runs two times.
You can register your event in creaturescripts.xml like so:
1
<movevent event="Equip" itemid="8891" slot="armor" script="pallyarmor.lua">
2
<vocation name="Paladin" />
3
<vocation name="Royal Paladin" showInDescription="0" />
Copied!
You can then call the event in a script like so:
pallyarmor.lua
1
function onEquip(player, item, slot, isCheck)
2
if isCheck then
3
return true -- we return true here because we don't want to apply anything until after armor is equipped.
4
end
5
6
player:setCapacity(player:getCapacity() + 20)
7
8
return true
9
end
Copied!
Must return true to equip without error!

onDeEquip(player, item, slot, isCheck)

  • player -- 1st arg/parameter /userdata/ = The player that is removing the item
  • item -- 2nd arg/parameter /userdata/ = The item that is being removed
  • slot -- 3rd arg/parameter /userdata/ = The slot that the item is being removed from.
  • isCheck -- 4th arg/parameter /userdata/ = is this before item is removed, true or false
onDeEquip runs twice everytime a player de-equips an item. It runs once before it is de-equipped, and runs again after. The parameter "isCheck" is true value the first time, before the item is de-equipped, and false the second time, after it is de-equipped. This is kind of unique to consider as it is one item with one registered event that runs two times.
You can register your event in creaturescripts.xml like so:
1
<movevent event="DeEquip" itemid="8891" slot="armor" script="pallyarmor.lua" />
Copied!
You can then call the event in a script like so:
pallyarmor.lua
1
function onDeEquip(player, item, slot, isCheck)
2
if isCheck then
3
return true -- we return true here because we don't want to apply anything until after armor is removed
4
end
5
6
player:setCapacity(player:getCapacity() - 20)
7
8
return true
9
end
Copied!
Must return true to remove item without error!