diff --git a/data/scripts/movements/special_tiles.lua b/data/scripts/movements/special_tiles.lua index eed5e6400b6..bccdf5b82f0 100644 --- a/data/scripts/movements/special_tiles.lua +++ b/data/scripts/movements/special_tiles.lua @@ -1,22 +1,29 @@ local increasing = { [419] = 420, [431] = 430, [452] = 453, [563] = 564, [549] = 562, [10145] = 10146 } local decreasing = { [420] = 419, [430] = 431, [453] = 452, [564] = 563, [562] = 549, [10146] = 10145 } -function Player:checkAndSendDepotMessage() +local function checkAndSendDepotMessage(player) for _, direction in ipairs(DIRECTIONS_TABLE) do - local playerPosition = self:getPosition() + local playerPosition = player:getPosition() playerPosition:getNextPosition(direction) - local depotItem = playerPosition:getTile():getItemByType(ITEM_TYPE_DEPOT) - if depotItem ~= nil or self:getGroup():getAccess() then - local depotItems = 0 - for id = 1, configManager.getNumber(configKeys.DEPOT_BOXES) do - depotItems = depotItems + self:getDepotChest(id, true):getItemHoldingCount() + + local tile = playerPosition:getTile() + if tile then + local depotItem = tile:getItemByType(ITEM_TYPE_DEPOT) + if depotItem then + local depotItems = 0 + for id = 1, configManager.getNumber(configKeys.DEPOT_BOXES) do + depotItems = depotItems + player:getDepotChest(id, true):getItemHoldingCount() + end + + local depotMessage = string.format("Your depot contains %d item%s", depotItems, depotItems ~= 1 and "s." or ".") + local stashMessage = string.format("Your supply stash contains %d item%s", player:getStashCount(), player:getStashCount() ~= 1 and "s." or ".") + + player:sendTextMessage(MESSAGE_STATUS, string.format("%s %s", depotMessage, stashMessage)) + player:setSpecialContainersAvailable(true, true, true) end - self:sendTextMessage(MESSAGE_STATUS, string.format("Your depot contains %d item%s Your supply stash contains %d item%s", depotItems, depotItems > 1 and "s." or ".", self:getStashCount(), self:getStashCount() > 1 and "s." or ".")) - self:setSpecialContainersAvailable(true, true, true) - return true end end - return false + return true end local tile = MoveEvent() @@ -27,10 +34,6 @@ function tile.onStepIn(creature, item, position, fromPosition) return true end - if player:isInGhostMode() then - return player:checkAndSendDepotMessage() - end - if not increasing[item.itemid] then return true end @@ -47,7 +50,7 @@ function tile.onStepIn(creature, item, position, fromPosition) end if Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then - return player:checkAndSendDepotMessage() + return checkAndSendDepotMessage(player) end if item.actionid ~= 0 and player:getStorageValue(item.actionid) <= 0 then