jareczekjsp
Member
Hello guys I try make max items per tile and I have error
Script
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onMoveItem
/home/ots/data/scripts/maxtile.lua:8: attempt to call method 'getTile' (a nil value)
stack traceback:
[C]: in function 'getTile'
/home/ots/data/scripts/maxtile.lua:8: in function 'callback'
/home/ots/data/scripts/lib/event_callbacks.lua:131: in function </home/ots/data/scripts/lib/event_callbacks.lua:124>
Script
Code:
local tileLimit = 0
local protectionTileLimit = 0
local houseTileLimit = 0
local ec = EventCallback
function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
local tile = toPosition:getTile()
if tile then
local itemLimit = tile:getHouse() and houseTileLimit or tile:hasFlag(TILESTATE_PROTECTIONZONE) and protectionTileLimit or tileLimit
if itemLimit > 0 and tile:getThingCount() > itemLimit and item:getType():getType() ~= ITEM_TYPE_MAGICFIELD then
player:sendCancelMessage("You can not add more items on this tile.")
return false
end
end
return true
end
ec:register(-1)