Skip to content

Commit

Permalink
add the failure because of protection
Browse files Browse the repository at this point in the history
  • Loading branch information
theFox6 committed Oct 17, 2021
1 parent 4bdbbac commit bf4760e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions working_villagers/async_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end
local drop_range = {x = 2, y = 10, z = 2}

function working_villages.villager:dig(pos,collect_drops)
if func.is_protected(self, pos) then return end
if func.is_protected(self, pos) then return false, fail.protected end
self.object:setvelocity{x = 0, y = 0, z = 0}
local dist = vector.subtract(pos, self.object:get_pos())
if vector.length(dist) > 5 then
Expand Down Expand Up @@ -166,7 +166,7 @@ function working_villages.villager:place(item,pos)
if type(pos)~="table" then
error("no target position given")
end
if func.is_protected(self,pos) then return end
if func.is_protected(self,pos) then return false, fail.protected end
local dist = vector.subtract(pos, self.object:get_pos())
if vector.length(dist) > 5 then
return false, fail.too_far
Expand Down
1 change: 1 addition & 0 deletions working_villagers/failures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local failures = {
too_far = "villager is too far away",
not_in_inventory = "villagers inventory doesn't contain item",
blocked = "a node blocks the position",
protected = "the target node is protected",
dig_fail = "dig_node returned false (eg. due to protected location)",
}

Expand Down

0 comments on commit bf4760e

Please sign in to comment.