From 939ca47e3c72e09e9f3fd311b2c80a3be856e76a Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 9 Jan 2025 15:39:08 +0100 Subject: [PATCH] Fix grid placement logic --- Modules/Config.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/Config.lua b/Modules/Config.lua index 585195e..d6a90f3 100644 --- a/Modules/Config.lua +++ b/Modules/Config.lua @@ -230,18 +230,24 @@ StaticGridFrame = { ---@param rowspan number ---@param colspan number Add = function(self, frame, rowspan, colspan) + if rowspan > self.rows or colspan > self.columns then + print("Rowspan or colspan exceeds grid dimensions.") + return + end + for row = 1, self.rows do for col = 1, self.columns do if not self.occupancy[row][col] then local canPlace = true for r = row, row + rowspan - 1 do for c = col, col + colspan - 1 do - if not self.occupancy[r] or self.occupancy[r][c] then + -- Check if r or c is out of bounds or if the cell is occupied + if r > self.rows or c > self.columns or self.occupancy[r][c] then canPlace = false break end - if not canPlace then break end end + if not canPlace then break end end if canPlace then local x = (col - 1) * self.cellWidth