FuturoAspira
New Member
Hello, could someone help me in a way to limit the amount of items in a tile?
I've tried with the onMoveItem event ... but it only checks items that "go to the player" and not the ones that go to the tile.
I've also tried with onItemMoved ... it checks the Tile(toPosition):getDownItemCount(), but it doesn't cancel or send the item with the return false
I've tried with the onMoveItem event ... but it only checks items that "go to the player" and not the ones that go to the tile.
I've also tried with onItemMoved ... it checks the Tile(toPosition):getDownItemCount(), but it doesn't cancel or send the item with the return false
Lua:
local ec = EventCallback
ec.onItemMoved = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
-- No move if item count > 10 items
local tile = Tile(toPosition)
if tile and tile:getDownItemCount() > 10 then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return false
end
return true
end
ec:register()