Improved handling of animals
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Wed, 28 Jun 2017 18:09:18 +0000 (20:09 +0200)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Wed, 28 Jun 2017 18:09:18 +0000 (20:09 +0200)
init.lua

index ecb8f37..e1da76f 100644 (file)
--- 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,