From 3776506b2fe33920a3f33d8f4441ccc2b6a6a2ab Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sat, 29 Oct 2016 16:45:47 +0100 Subject: [PATCH] using mobs:spawn functions to spawn animals --- bee.lua | 15 +++++++++++---- bunny.lua | 10 ++++++++-- chicken.lua | 10 ++++------ cow.lua | 11 +++++++++-- kitten.lua | 11 +++++++++-- rat.lua | 4 ++-- sheep.lua | 12 +++++++++--- warthog.lua | 11 +++++++++-- 8 files changed, 61 insertions(+), 23 deletions(-) diff --git a/bee.lua b/bee.lua index b64cdd1..d187874 100644 --- a/bee.lua +++ b/bee.lua @@ -41,7 +41,14 @@ mobs:register_mob("mobs_animal:bee", { end, }) -mobs:register_spawn("mobs_animal:bee", {"group:flower"}, 20, 10, 9000, 1, 31000, true) +mobs:spawn({ + name = "mobs_animal:bee", + nodes = {"group:flower"}, + min_light = 10, + chance = 9000, + min_height = 0, + day_toggle = true, +}) mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png", 0) @@ -81,7 +88,7 @@ minetest.register_node(":mobs:beehive", { meta:get_inventory():set_size("beehive", 1) end, ---[[ + after_place_node = function(pos, placer, itemstack) if placer:is_player() then @@ -89,11 +96,11 @@ minetest.register_node(":mobs:beehive", { minetest.set_node(pos, {name = "mobs:beehive", param2 = 1}) if math.random(1, 4) == 1 then - minetest.add_entity(pos, "mobs:bee") + minetest.add_entity(pos, "mobs_animal:bee") end end end, -]] + on_punch = function(pos, node, puncher) -- yep, bee's don't like having their home punched by players diff --git a/bunny.lua b/bunny.lua index ee8f6e9..0481991 100644 --- a/bunny.lua +++ b/bunny.lua @@ -80,8 +80,14 @@ mobs:register_mob("mobs_animal:bunny", { damage = 5, }) -mobs:register_spawn("mobs_animal:bunny", - {"default:dirt_with_grass", "ethereal:prairie_dirt"}, 20, 10, 15000, 1, 31000, true) +mobs:spawn({ + name = "mobs_animal:bunny", + nodes = {"default:dirt_with_grass", "ethereal:prairie_dirt"}, + min_light = 10, + chance = 15000, + min_height = 0, + day_toggle = true, +}) mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0) diff --git a/chicken.lua b/chicken.lua index e73a7c6..6b3a2bf 100644 --- a/chicken.lua +++ b/chicken.lua @@ -78,15 +78,13 @@ mobs:register_mob("mobs_animal:chicken", { end, }) ---mobs:register_spawn("mobs_animal:chicken", --- {"default:dirt_with_grass", "ethereal:bamboo_dirt"}, 20, 10, 15000, 2, 31000, true) - mobs:spawn({ name = "mobs_animal:chicken", nodes = {"default:dirt_with_grass", "ethereal:bamboo_dirt"}, - interval = 1, - chance = 12000, - active_object_count = 1, + min_light = 10, + chance = 15000, + active_object_count = 2, + min_height = 0, day_toggle = true, }) diff --git a/cow.lua b/cow.lua index 72b3e44..02e6f0b 100644 --- a/cow.lua +++ b/cow.lua @@ -95,8 +95,15 @@ mobs:register_mob("mobs_animal:cow", { end, }) -mobs:register_spawn("mobs_animal:cow", - {"default:dirt_with_grass", "ethereal:green_dirt"}, 20, 10, 15000, 1, 31000, true) +mobs:spawn({ + name = "mobs_animal:cow", + nodes = {"default:dirt_with_grass", "ethereal:green_dirt"}, + min_light = 10, + chance = 15000, + min_height = 0, + max_height = 31000, + day_toggle = true, +}) mobs:register_egg("mobs_animal:cow", S("Cow"), "default_grass.png", 1) diff --git a/kitten.lua b/kitten.lua index 499ce77..90a94d9 100644 --- a/kitten.lua +++ b/kitten.lua @@ -52,8 +52,15 @@ mobs:register_mob("mobs_animal:kitten", { end }) -mobs:register_spawn("mobs_animal:kitten", - {"default:dirt_with_grass", "ethereal:grove_dirt"}, 20, 12, 22000, 1, 31000, true) +mobs:spawn({ + name = "mobs_animal:kitten", + nodes = {"default:dirt_with_grass", "ethereal:grove_dirt"}, + min_light = 12, + chance = 22000, + min_height = 0, + max_height = 31000, + day_toggle = true, +}) mobs:register_egg("mobs_animal:kitten", S("Kitten"), "mobs_kitten_inv.png", 0) diff --git a/rat.lua b/rat.lua index 9f4e1ef..8322cb2 100644 --- a/rat.lua +++ b/rat.lua @@ -57,8 +57,6 @@ mobs:register_mob("mobs_animal:rat", { ]] }) ---mobs:register_spawn("mobs_animal:rat", {"default:stone"}, 20, 5, 15000, 2, 0) - local function rat_spawn(self, pos) print (self:get_luaentity().name, pos.x, pos.y, pos.z) end @@ -66,6 +64,8 @@ end mobs:spawn({ name = "mobs_animal:rat", nodes = {"default:stone"}, + min_light = 3, + active_object_count = 2, max_height = 0, -- on_spawn = rat_spawn, }) diff --git a/sheep.lua b/sheep.lua index 37b9157..465321c 100644 --- a/sheep.lua +++ b/sheep.lua @@ -177,9 +177,15 @@ for _, col in pairs(all_colours) do end -mobs:register_spawn("mobs_animal:sheep_white", - {"default:dirt_with_grass", "ethereal:green_dirt"}, 20, 10, 15000, 1, 31000, true) - +mobs:spawn({ + name = "mobs_animal:sheep_white", + nodes = {"default:dirt_with_grass", "ethereal:green_dirt"}, + min_light = 10, + chance = 15000, + min_height = 0, + max_height = 31000, + day_toggle = true, +}) -- compatibility mobs:alias_mob("mobs:sheep", "mobs_animal:sheep_white") diff --git a/warthog.lua b/warthog.lua index aa62db2..e9cfbb6 100644 --- a/warthog.lua +++ b/warthog.lua @@ -55,8 +55,15 @@ mobs:register_mob("mobs_animal:pumba", { end, }) -mobs:register_spawn("mobs_animal:pumba", - {"ethereal:mushroom_dirt", "default:dirt_with_dry_grass"}, 20, 10, 15000, 1, 31000, true) +mobs:spawn({ + name = "mobs_animal:pumba", + nodes = {"default:dirt_with_dry_grass", "ethereal:mushroom_dirt"}, + min_light = 10, + chance = 15000, + min_height = 0, + max_height = 31000, + day_toggle = true, +}) mobs:register_egg("mobs_animal:pumba", S("Warthog"), "wool_pink.png", 1)