From c85fa381934175c0bc9fa4214b5ebb451fcb017e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B5=D1=80=D1=85=D0=B0=D1=80=D0=B4=20PICCORO=20Len?= =?UTF-8?q?z=20McKAY?= Date: Fri, 21 Jan 2022 12:37:52 -0400 Subject: [PATCH] Make owl tamable, with compatibility and right code checks * cherry picked from https://github.com/BlockySurvival/mobs_animal_pack/pull/6 * not change namespace neither idents --- mobs/owl.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/mobs/owl.lua b/mobs/owl.lua index d2d8fb8..20dd073 100644 --- a/mobs/owl.lua +++ b/mobs/owl.lua @@ -1,3 +1,45 @@ +local follow = {} + +-- detect common minetest famous mobs +if minetest.get_modpath("farming") then + table.insert(follow, "farming:seed_wheat") + table.insert(follow, "farming:seed_cotton") +end +if minetest.get_modpath("butterflies") then + table.insert(follow, "butterflies:butterfly_red") + table.insert(follow, "butterflies:butterfly_violet") + table.insert(follow, "butterflies:butterfly_white") +end +if minetest.get_modpath("fireflies") then + table.insert(follow, "fireflies:firefly") +end +if minetest.get_modpath("mobs_animal") then + table.insert(follow, "mobs_animal:rat") + table.insert(follow, "mobs_animal:bee") + table.insert(follow, "mobs_animal:bunny") + table.insert(follow, "mobs_animal:chicken") +end +-- compatibility with those made specially for other games +if minetest.get_modpath("mobs_bugslive") then + table.insert(follow, "mobs_bugslive:bug") +end +if minetest.get_modpath("mobs_butterfly") then + table.insert(follow, "mobs_butterfly:butterfly") +end +if minetest.get_modpath("mobs_fish") then + table.insert(follow, "mobs_fish:tropical") + table.insert(follow, "mobs_fish:clownfish") +end +if minetest.get_modpath("mobs_better_rat") then + table.insert(follow, "mobs_better_rat:rat") +end +if minetest.get_modpath("mobs_bat") then + table.insert(follow, "mobs_bat:bat") +end +if minetest.get_modpath("mobs_birds") then + table.insert(follow, "mobs_birds:bird_sm") +end + mobs:register_mob("dmobs:owl", { type = "animal", passive = true, @@ -20,6 +62,7 @@ mobs:register_mob("dmobs:owl", { lava_damage = 2, light_damage = 0, view_range = 1, + follow=follow, do_custom = function(self) local daytime = minetest.get_timeofday()*24000 if daytime <=6000 then @@ -34,6 +77,11 @@ mobs:register_mob("dmobs:owl", { }) end end, + on_rightclick = function(self, clicker) + if mobs:feed_tame(self, clicker, 8, true, true) then return end + if mobs:protect(self, clicker) then return end + mobs:capture_mob(self, clicker, 0, 50, 5, false, nil) + end, animation = { speed_normal = 1, walk_start = 1,