mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-01 07:13:45 +01:00
Villagers will now pathfind to town bell that isn't on the ground
This commit is contained in:
parent
856a60bcc2
commit
9b1ceebf0d
@ -35,19 +35,20 @@ function append_paths (wp1, wp2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function output_enriched (wp_out)
|
local function output_enriched (wp_out)
|
||||||
mcl_log("Output enriched path")
|
--mcl_log("Output enriched path")
|
||||||
local i = 0
|
local i = 0
|
||||||
for _,outy in pairs (wp_out) do
|
for _,outy in pairs (wp_out) do
|
||||||
i = i + 1
|
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"]
|
local action = outy["action"]
|
||||||
if action then
|
if action then
|
||||||
|
mcl_log("Pos ".. i ..":" .. minetest.pos_to_string(outy["pos"]))
|
||||||
mcl_log("type: " .. action["type"])
|
mcl_log("type: " .. action["type"])
|
||||||
mcl_log("action: " .. action["action"])
|
mcl_log("action: " .. action["action"])
|
||||||
mcl_log("target: " .. minetest.pos_to_string(action["target"]))
|
mcl_log("target: " .. minetest.pos_to_string(action["target"]))
|
||||||
end
|
end
|
||||||
mcl_log("failed attempts: " .. outy["failed_attempts"])
|
--mcl_log("failed attempts: " .. outy["failed_attempts"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1190,6 +1190,19 @@ local function do_work (self)
|
|||||||
end
|
end
|
||||||
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)
|
local function go_to_town_bell(self)
|
||||||
if self.order == GATHERING then
|
if self.order == GATHERING then
|
||||||
mcl_log("Already gathering")
|
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.
|
--Ideally should check for closest available. It'll make pathing easier.
|
||||||
for _,n in pairs(nn) do
|
for _,n in pairs(nn) do
|
||||||
mcl_log("Found bell")
|
mcl_log("Found bell")
|
||||||
|
local target_point = get_ground_below_floating_object(n)
|
||||||
|
|
||||||
local gp = self:gopath(n,function(self)
|
local gp = self:gopath(target_point,function(self)
|
||||||
if self then
|
if self then
|
||||||
self.order = GATHERING
|
self.order = GATHERING
|
||||||
mcl_log("Callback has a self")
|
mcl_log("Callback has a self")
|
||||||
|
Loading…
Reference in New Issue
Block a user