diff --git a/housing/construction.lua b/housing/construction.lua index 94c88dd43..c97445cde 100644 --- a/housing/construction.lua +++ b/housing/construction.lua @@ -219,7 +219,7 @@ local function showTemporaryPreviewOfItem(productId, user, isTile) return end - if not utility.wallWindowPermissions(user, frontPos, productId, isTile) then + if not utility.wallWindowPermissions(user, frontPos, productId, isTile) or utility.checkIfEntrance(user, frontPos, isTile) then return end @@ -370,7 +370,7 @@ local function createItem(user, product, trowel, skill) world:changeTile(product.id, target) end else - if not utility.wallWindowPermissions(user, target, product.id, product.tile) then + if not utility.wallWindowPermissions(user, target, product.id, product.tile) or utility.checkIfEntrance(user, target, product.tile) then return end @@ -527,7 +527,7 @@ function M.showDialog(user, skillName, carpentryEstateCatalogue) end end - if not utility.wallWindowPermissions(user, frontPos, product.id, product.tile) or not hasMaterials(user, product) then + if not utility.wallWindowPermissions(user, frontPos, product.id, product.tile) or not hasMaterials(user, product) or utility.checkIfEntrance(user, frontPos, product.tile) then canWork = false end diff --git a/housing/utility.lua b/housing/utility.lua index 546c4b2af..d8f280645 100644 --- a/housing/utility.lua +++ b/housing/utility.lua @@ -255,15 +255,21 @@ function M.checkIfEstateViaName(propertyName) end -local function checkIfEntrance(user) +function M.checkIfEntrance(user, pos, tile) - if M.checkIfEstate(user) then + if M.checkIfEstate(user) then --Estates are allowed to build on entrances return false end - local targetItem = common.GetFrontItem(user) + if tile then + return false -- You can build a tile under entrances + end - if not targetItem then + local targetItem + + if world:isItemOnField(pos) then + targetItem = world:getItemOnField(pos) + else return false end @@ -409,10 +415,6 @@ end function M.allowBuilding(user, alternatePosition) - if checkIfEntrance(user) then - return false - end - local frontPos = common.GetFrontPosition(user) if alternatePosition then frontPos = alternatePosition