From 539c2b8329f98b87fe227261ae28d156c02f870a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Wed, 28 Jun 2017 20:09:18 +0200 Subject: Improved handling of animals --- init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index ecb8f37..e1da76f 100644 --- a/init.lua +++ b/init.lua @@ -159,7 +159,7 @@ minetest.register_abm({ interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - local all_objects = minetest.get_objects_inside_radius(pos, 0.75) + local all_objects = minetest.get_objects_inside_radius(pos, 1) local _,obj for _,obj in ipairs(all_objects) do @@ -170,10 +170,12 @@ minetest.register_abm({ local name = obj:get_player_name() default.player_attached[name] = true elseif obj:get_luaentity() and string.sub(obj:get_luaentity().name,1,string.len("mobs_animal")) == "mobs_animal" then - dum = walkway.do_moving_dummy({x = pos.x, y = pos.y + 0.15, z = pos.z}, obj):get_luaentity() - dum.player = obj --- minetest.chat_send_all("Attaching "..obj:get_luaentity().name) - obj:set_attach(dum.object, "", {x=0,y=-1,z=0}, {x=0,y=0,z=0}) + local napos = minetest.get_node(pos) + local dir = vector.new(minetest.facedir_to_dir(napos.param2)) + obj:setvelocity({x = dir.x / speed, y = 0, z = dir.z / speed}) +-- dum = walkway.do_moving_dummy({x = pos.x, y = pos.y + 0.15, z = pos.z}, obj):get_luaentity() +-- dum.player = obj +-- obj:set_attach(dum.object, "", {x=0,y=-1,z=0}, {x=0,y=0,z=0}) end end end, -- cgit v1.2.3