Fix slotsperrow

This commit is contained in:
2025-03-30 20:34:32 +02:00
parent a574e56c1c
commit dc5080039a

View File

@@ -64,7 +64,15 @@ local function tryUnloadSlot(slot)
-- print("Before sorting:")
-- dump(nearbySlots)
local slotsPerRow = slot.inventory.slotsPerRow or 1
-- Some inventories don't have slots per row, like the player inventory
local slotsPerRow = 900
local ok, err = pcall(function()
slotsPerRow = slot.inventory.slotsPerRow
end)
if not ok then
MyModGlobal.debugPrint(string.format("Error getting slots per row: %s", err))
end
local getGridPos = function(slotIndex)
local x = slotIndex % slotsPerRow
local y = math.floor(slotIndex / slotsPerRow)