Skip to content

Commit

Permalink
Move of entrance check
Browse files Browse the repository at this point in the history
  • Loading branch information
brightrim committed Jan 18, 2024
1 parent 344d929 commit 3da938e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions housing/construction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
18 changes: 10 additions & 8 deletions housing/utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3da938e

Please sign in to comment.