<event class="Player" method="onMoveItem" enabled="1" />
function Player:onMoveItem(item, count, fromPosition, toPosition)
-- DROP
local npc = toPosition:getTile():getTopCreature() -- or Tile(toPosition):getTopCreature()
if npc and npc:getName() == "Sonya" then
-- stuffs
-- return true
end
-- DRAG
local npc = fromPosition:getTile():getTopCreature() -- or Tile(fromPosition):getTopCreature()
if npc and npc:getName() == "Sonya" then
-- stuffs
-- return true
end
If getTile returns nil whole function breaks with nil value error.Here you have an alternative! they are two examples.
I hope I'm not wrong, this is what you wanted?
events.xml
Code:<event class="Player" method="onMoveItem" enabled="1" />
events/scripts/player.lua
Code:function Player:onMoveItem(item, count, fromPosition, toPosition) -- DROP local npc = toPosition:getTile():getTopCreature() -- or Tile(toPosition):getTopCreature() if npc and npc:getName() == "Sonya" then -- stuffs -- return true end -- DRAG local npc = fromPosition:getTile():getTopCreature() -- or Tile(fromPosition):getTopCreature() if npc and npc:getName() == "Sonya" then -- stuffs -- return true end
Thanks i try this.Here you have an alternative! they are two examples.
I hope I'm not wrong, this is what you wanted?
events.xml
Code:<event class="Player" method="onMoveItem" enabled="1" />
events/scripts/player.lua
Code:function Player:onMoveItem(item, count, fromPosition, toPosition) -- DROP local npc = toPosition:getTile():getTopCreature() -- or Tile(toPosition):getTopCreature() if npc and npc:getName() == "Sonya" then -- stuffs -- return true end -- DRAG local npc = fromPosition:getTile():getTopCreature() -- or Tile(fromPosition):getTopCreature() if npc and npc:getName() == "Sonya" then -- stuffs -- return true end