From 6548b7fe4753f57158ebd23dd73300c07f1f1529 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 10 Nov 2022 21:23:00 +0100 Subject: [PATCH] move stray pathfinding funcs to pathfinding file --- mods/ENTITIES/mcl_mobs/movement.lua | 49 -------------------------- mods/ENTITIES/mcl_mobs/pathfinding.lua | 48 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index cbc0182c2..642f513d1 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -719,55 +719,6 @@ function mob_class:go_to_pos(b) self:set_animation("walk") end -function mob_class:interact_with_door(action, target) - local p = self.object:get_pos() - --local t = minetest.get_timeofday() - --local dd = minetest.find_nodes_in_area(vector.offset(p,-1,-1,-1),vector.offset(p,1,1,1),{"group:door"}) - --for _,d in pairs(dd) do - if target then - mcl_log("Door target is: ".. minetest.pos_to_string(target)) - - local n = minetest.get_node(target) - if n.name:find("_b_") or n.name:find("_t_") then - mcl_log("Door") - local def = minetest.registered_nodes[n.name] - local closed = n.name:find("_b_1") or n.name:find("_t_1") - --if self.state == PATHFINDING then - if closed and action == "open" and def.on_rightclick then - mcl_log("Open door") - def.on_rightclick(target,n,self) - end - if not closed and action == "close" and def.on_rightclick then - mcl_log("Close door") - def.on_rightclick(target,n,self) - end - --else - else - mcl_log("Not door") - end - else - mcl_log("no target. cannot try and open or close door") - end - --end -end - -function mob_class:do_pathfind_action(action) - if action then - mcl_log("Action present") - local type = action["type"] - local action_val = action["action"] - local target = action["target"] - if target then - mcl_log("Target: ".. minetest.pos_to_string(target)) - end - if type and type == "door" then - mcl_log("Type is door") - self:interact_with_door(action_val, target) - end - end -end - - local check_herd_timer = 0 function mob_class:check_herd(dtime) local pos = self.object:get_pos() diff --git a/mods/ENTITIES/mcl_mobs/pathfinding.lua b/mods/ENTITIES/mcl_mobs/pathfinding.lua index bef22ef5e..2bab7524e 100644 --- a/mods/ENTITIES/mcl_mobs/pathfinding.lua +++ b/mods/ENTITIES/mcl_mobs/pathfinding.lua @@ -219,6 +219,54 @@ function mob_class:gopath(target,callback_arrived) end end +function mob_class:interact_with_door(action, target) + local p = self.object:get_pos() + --local t = minetest.get_timeofday() + --local dd = minetest.find_nodes_in_area(vector.offset(p,-1,-1,-1),vector.offset(p,1,1,1),{"group:door"}) + --for _,d in pairs(dd) do + if target then + mcl_log("Door target is: ".. minetest.pos_to_string(target)) + + local n = minetest.get_node(target) + if n.name:find("_b_") or n.name:find("_t_") then + mcl_log("Door") + local def = minetest.registered_nodes[n.name] + local closed = n.name:find("_b_1") or n.name:find("_t_1") + --if self.state == PATHFINDING then + if closed and action == "open" and def.on_rightclick then + mcl_log("Open door") + def.on_rightclick(target,n,self) + end + if not closed and action == "close" and def.on_rightclick then + mcl_log("Close door") + def.on_rightclick(target,n,self) + end + --else + else + mcl_log("Not door") + end + else + mcl_log("no target. cannot try and open or close door") + end + --end +end + +function mob_class:do_pathfind_action(action) + if action then + mcl_log("Action present") + local type = action["type"] + local action_val = action["action"] + local target = action["target"] + if target then + mcl_log("Target: ".. minetest.pos_to_string(target)) + end + if type and type == "door" then + mcl_log("Type is door") + self:interact_with_door(action_val, target) + end + end +end + local gowp_etime = 0 function mob_class:check_gowp(dtime)