mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-04 23:31:05 +01:00
Villagers will now pathfind to town bell that isn't on the ground
This commit is contained in:
parent
856a60bcc2
commit
9b1ceebf0d
2 changed files with 20 additions and 5 deletions
|
@ -35,19 +35,20 @@ function append_paths (wp1, wp2)
|
|||
end
|
||||
|
||||
local function output_enriched (wp_out)
|
||||
mcl_log("Output enriched path")
|
||||
--mcl_log("Output enriched path")
|
||||
local i = 0
|
||||
for _,outy in pairs (wp_out) do
|
||||
i = i + 1
|
||||
mcl_log("Pos ".. i ..":" .. minetest.pos_to_string(outy["pos"]))
|
||||
--mcl_log("Pos ".. i ..":" .. minetest.pos_to_string(outy["pos"]))
|
||||
|
||||
local action = outy["action"]
|
||||
if action then
|
||||
mcl_log("Pos ".. i ..":" .. minetest.pos_to_string(outy["pos"]))
|
||||
mcl_log("type: " .. action["type"])
|
||||
mcl_log("action: " .. action["action"])
|
||||
mcl_log("target: " .. minetest.pos_to_string(action["target"]))
|
||||
end
|
||||
mcl_log("failed attempts: " .. outy["failed_attempts"])
|
||||
--mcl_log("failed attempts: " .. outy["failed_attempts"])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1190,6 +1190,19 @@ local function do_work (self)
|
|||
end
|
||||
end
|
||||
|
||||
local below_vec = vector.new(0, -1, 0)
|
||||
|
||||
local function get_ground_below_floating_object (float_pos)
|
||||
local pos = float_pos
|
||||
repeat
|
||||
mcl_log("Current pos: " .. minetest.pos_to_string(pos))
|
||||
pos = vector.add(pos, below_vec)
|
||||
local node = minetest.get_node(pos)
|
||||
mcl_log("First non air materials: ".. tostring(node.name))
|
||||
until node.name ~= "air"
|
||||
return pos
|
||||
end
|
||||
|
||||
local function go_to_town_bell(self)
|
||||
if self.order == GATHERING then
|
||||
mcl_log("Already gathering")
|
||||
|
@ -1208,8 +1221,9 @@ local function go_to_town_bell(self)
|
|||
--Ideally should check for closest available. It'll make pathing easier.
|
||||
for _,n in pairs(nn) do
|
||||
mcl_log("Found bell")
|
||||
|
||||
local gp = self:gopath(n,function(self)
|
||||
local target_point = get_ground_below_floating_object(n)
|
||||
|
||||
local gp = self:gopath(target_point,function(self)
|
||||
if self then
|
||||
self.order = GATHERING
|
||||
mcl_log("Callback has a self")
|
||||
|
|
Loading…
Reference in a new issue