tweak and tidy code

This commit is contained in:
tenplus1 2024-08-10 14:10:22 +01:00
parent 10865e9ab4
commit 53f72b8a9e
14 changed files with 243 additions and 345 deletions

75
bee.lua
View File

@ -1,8 +1,5 @@
-- Translation support
local S = minetest.get_translator("mobs_animal")
-- check for default mod local S = minetest.get_translator("mobs_animal")
local mod_def = minetest.get_modpath("default")
-- Bee by KrupnoPavel (.b3d model by sirrobzeroone) -- Bee by KrupnoPavel (.b3d model by sirrobzeroone)
@ -15,15 +12,11 @@ mobs:register_mob("mobs_animal:bee", {
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.5, 0.2}, collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.5, 0.2},
visual = "mesh", visual = "mesh",
mesh = "mobs_bee.b3d", mesh = "mobs_bee.b3d",
textures = { textures = { {"mobs_bee.png"} },
{"mobs_bee.png"}
},
blood_texture = "mobs_bee_inv.png", blood_texture = "mobs_bee_inv.png",
blood_amount = 1, blood_amount = 1,
makes_footstep_sound = false, makes_footstep_sound = false,
sounds = { sounds = { random = "mobs_bee" },
random = "mobs_bee"
},
walk_velocity = 1, walk_velocity = 1,
jump = true, jump = true,
drops = { drops = {
@ -36,10 +29,8 @@ mobs:register_mob("mobs_animal:bee", {
fall_speed = -3, fall_speed = -3,
animation = { animation = {
speed_normal = 15, speed_normal = 15,
stand_start = 0, stand_start = 0, stand_end = 30,
stand_end = 30, walk_start = 35, walk_end = 65
walk_start = 35,
walk_end = 65
}, },
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
@ -51,6 +42,8 @@ mobs:register_mob("mobs_animal:bee", {
-- end, -- end,
}) })
-- where to spawn
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
mobs:spawn({ mobs:spawn({
@ -65,16 +58,16 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg -- spawn egg
mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png") mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png")
-- compatibility (only required if moving from old mobs to mobs_redo) -- compatibility (only required if moving from old mobs to mobs_redo)
mobs:alias_mob("mobs:bee", "mobs_animal:bee") mobs:alias_mob("mobs:bee", "mobs_animal:bee")
-- honey -- honey
minetest.register_craftitem(":mobs:honey", { minetest.register_craftitem(":mobs:honey", {
description = S("Honey"), description = S("Honey"),
inventory_image = "mobs_honey_inv.png", inventory_image = "mobs_honey_inv.png",
@ -84,7 +77,8 @@ minetest.register_craftitem(":mobs:honey", {
mobs.add_eatable("mobs:honey", 4) mobs.add_eatable("mobs:honey", 4)
-- beehive (when placed spawns bee) -- beehive (1 in 4 chance of spawning bee when placed)
minetest.register_node(":mobs:beehive", { minetest.register_node(":mobs:beehive", {
description = S("Beehive"), description = S("Beehive"),
drawtype = "plantlike", drawtype = "plantlike",
@ -95,7 +89,7 @@ minetest.register_node(":mobs:beehive", {
walkable = true, walkable = true,
groups = {oddly_breakable_by_hand = 3, flammable = 1, disable_suffocation = 1}, groups = {oddly_breakable_by_hand = 3, flammable = 1, disable_suffocation = 1},
is_ground_content = false, is_ground_content = false,
sounds = mod_def and default.node_sound_defaults(), sounds = mobs.node_sound_defaults(),
on_construct = function(pos) on_construct = function(pos)
@ -131,48 +125,42 @@ minetest.register_node(":mobs:beehive", {
local hp = puncher and puncher:get_hp() local hp = puncher and puncher:get_hp()
if hp then if hp then puncher:set_hp(hp - 4) end
puncher:set_hp(hp - 4)
end
end) end)
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "beehive" then if listname == "beehive" then return 0 end
return 0
end
return stack:get_count() return stack:get_count()
end, end,
can_dig = function(pos,player) can_dig = function(pos,player) -- can only dig when no honey inside
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
-- only dig beehive if no honey inside
return meta:get_inventory():is_empty("beehive") return meta:get_inventory():is_empty("beehive")
end end
}) })
-- beehive recipe -- beehive recipe
minetest.register_craft({ minetest.register_craft({
output = "mobs:beehive", output = "mobs:beehive",
recipe = { recipe = {{"mobs:bee","mobs:bee","mobs:bee"}}
{"mobs:bee","mobs:bee","mobs:bee"}
}
}) })
-- honey block -- honey block and craft recipes
minetest.register_node(":mobs:honey_block", { minetest.register_node(":mobs:honey_block", {
description = S("Honey Block"), description = S("Honey Block"),
tiles = {"mobs_honey_block.png"}, tiles = {"mobs_honey_block.png"},
groups = {snappy = 3, flammable = 2}, groups = {snappy = 3, flammable = 2},
is_ground_content = false, is_ground_content = false,
sounds = mod_def and default.node_sound_dirt_defaults() sounds = mobs.node_sound_dirt_defaults()
}) })
-- recipe
minetest.register_craft({ minetest.register_craft({
output = "mobs:honey_block", output = "mobs:honey_block",
recipe = { recipe = {
@ -189,38 +177,31 @@ minetest.register_craft({
} }
}) })
-- beehive workings -- beehive workings
minetest.register_abm({ minetest.register_abm({
nodenames = {"mobs:beehive"}, nodenames = {"mobs:beehive"},
interval = 12, interval = 12,
chance = 6, chance = 6,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
-- bee's only make honey during the day -- bee's only make honey during the day
local tod = (minetest.get_timeofday() or 0) * 24000 local tod = (minetest.get_timeofday() or 0) * 24000
if tod < 5500 or tod > 18500 then if tod < 5500 or tod > 18500 then return end
return
end
-- is hive full? local meta = minetest.get_meta(pos) ; if not meta then return end
local meta = minetest.get_meta(pos)
if not meta then return end -- for older beehives
local inv = meta:get_inventory() local inv = meta:get_inventory()
local honey = inv:get_stack("beehive", 1):get_count() local honey = inv:get_stack("beehive", 1):get_count()
-- is hive full? if honey > 11 then return end -- return if hive full
if honey > 11 then
return
end
-- no flowers no honey, nuff said! -- no flowers no honey, nuff said!
if #minetest.find_nodes_in_area_under_air( if #minetest.find_nodes_in_area_under_air(
{x = pos.x - 4, y = pos.y - 3, z = pos.z - 4}, {x = pos.x - 4, y = pos.y - 3, z = pos.z - 4},
{x = pos.x + 4, y = pos.y + 3, z = pos.z + 4}, {x = pos.x + 4, y = pos.y + 3, z = pos.z + 4}, "group:flower") > 3 then
"group:flower") > 3 then
inv:add_item("beehive", "mobs:honey") inv:add_item("beehive", "mobs:honey")
end end

View File

@ -1,4 +1,4 @@
-- Translation support
local S = minetest.get_translator("mobs_animal") local S = minetest.get_translator("mobs_animal")
-- Bunny by ExeterDad -- Bunny by ExeterDad
@ -38,12 +38,9 @@ mobs:register_mob("mobs_animal:bunny", {
fear_height = 2, fear_height = 2,
animation = { animation = {
speed_normal = 15, speed_normal = 15,
stand_start = 1, stand_start = 1, stand_end = 15,
stand_end = 15, walk_start = 16, walk_end = 24,
walk_start = 16, punch_start = 16, punch_end = 24
walk_end = 24,
punch_start = 16,
punch_end = 24
}, },
follow = {"farming:carrot", "farming_plus:carrot_item", "default:grass_1"}, follow = {"farming:carrot", "farming_plus:carrot_item", "default:grass_1"},
view_range = 8, view_range = 8,
@ -93,9 +90,7 @@ mobs:register_mob("mobs_animal:bunny", {
obj:set_properties({textures = {"mobs_bunny_evil.png"}, hp_max = 20}) obj:set_properties({textures = {"mobs_bunny_evil.png"}, hp_max = 20})
-- remove old bunny -- remove old bunny
if obj:get_luaentity() then if obj:get_luaentity() then mobs:remove(self, true) end
mobs:remove(self, true)
end
end end
end, end,
@ -126,15 +121,16 @@ mobs:register_mob("mobs_animal:bunny", {
end end
}) })
-- where to spawn
local spawn_on = "default:dirt_with_grass"
if minetest.get_modpath("ethereal") then
spawn_on = "ethereal:prairie_dirt"
end
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
local spawn_on = "default:dirt_with_grass"
if minetest.get_modpath("ethereal") then
spawn_on = "ethereal:prairie_dirt"
end
mobs:spawn({ mobs:spawn({
name = "mobs_animal:bunny", name = "mobs_animal:bunny",
nodes = {spawn_on}, nodes = {spawn_on},
@ -148,14 +144,16 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0) mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0)
-- compatibility (only used for older mobs compatibility)
mobs:alias_mob("mobs:bunny", "mobs_animal:bunny") -- compatibility mobs:alias_mob("mobs:bunny", "mobs_animal:bunny")
-- raw rabbit -- raw rabbit
minetest.register_craftitem(":mobs:rabbit_raw", { minetest.register_craftitem(":mobs:rabbit_raw", {
description = S("Raw Rabbit"), description = S("Raw Rabbit"),
inventory_image = "mobs_rabbit_raw.png", inventory_image = "mobs_rabbit_raw.png",
@ -166,6 +164,7 @@ minetest.register_craftitem(":mobs:rabbit_raw", {
mobs.add_eatable("mobs:rabbit_raw", 3) mobs.add_eatable("mobs:rabbit_raw", 3)
-- cooked rabbit -- cooked rabbit
minetest.register_craftitem(":mobs:rabbit_cooked", { minetest.register_craftitem(":mobs:rabbit_cooked", {
description = S("Cooked Rabbit"), description = S("Cooked Rabbit"),
inventory_image = "mobs_rabbit_cooked.png", inventory_image = "mobs_rabbit_cooked.png",
@ -182,18 +181,15 @@ minetest.register_craft({
cooktime = 5 cooktime = 5
}) })
-- rabbit hide -- rabbit hide and recipes
minetest.register_craftitem(":mobs:rabbit_hide", { minetest.register_craftitem(":mobs:rabbit_hide", {
description = S("Rabbit Hide"), description = S("Rabbit Hide"),
inventory_image = "mobs_rabbit_hide.png", inventory_image = "mobs_rabbit_hide.png",
groups = {flammable = 2, pelt = 1} groups = {flammable = 2, pelt = 1}
}) })
minetest.register_craft({ minetest.register_craft({type = "fuel", recipe = "mobs:rabbit_hide", burntime = 2})
type = "fuel",
recipe = "mobs:rabbit_hide",
burntime = 2
})
minetest.register_craft({ minetest.register_craft({
output = "mobs:leather", output = "mobs:leather",

View File

@ -1,4 +1,4 @@
-- Translation support
local S = minetest.get_translator("mobs_animal") local S = minetest.get_translator("mobs_animal")
-- Chicken by JK Murray and Sirrobzeroone -- Chicken by JK Murray and Sirrobzeroone
@ -18,13 +18,9 @@ mobs:register_mob("mobs_animal:chicken", {
{"mobs_chicken_brown.png"}, {"mobs_chicken_brown.png"},
{"mobs_chicken_black.png"} {"mobs_chicken_black.png"}
}, },
child_texture = { child_texture = {{"mobs_chick.png"}},
{"mobs_chick.png"}
},
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {random = "mobs_chicken"},
random = "mobs_chicken"
},
walk_velocity = 1, walk_velocity = 1,
run_velocity = 3, run_velocity = 3,
runaway = true, runaway = true,
@ -41,18 +37,10 @@ mobs:register_mob("mobs_animal:chicken", {
fear_height = 5, fear_height = 5,
animation = { animation = {
speed_normal = 15, speed_normal = 15,
stand_start = 1, stand_start = 1, stand_end = 30, stand_speed = 28,
stand_end = 30, stand1_start = 31, stand1_end = 70, stand1_speed = 32,
stand_speed = 28, walk_start = 71, walk_end = 90, walk_speed = 24,
stand1_start = 31, run_start = 91, run_end = 110, run_speed = 24
stand1_end = 70,
stand1_speed = 32,
walk_start = 71,
walk_end = 90,
walk_speed = 24,
run_start = 91,
run_end = 110,
run_speed = 24
}, },
follow = { follow = {
"farming:seed_wheat", "farming:seed_cotton", "farming:seed_barley", "farming:seed_wheat", "farming:seed_cotton", "farming:seed_barley",
@ -84,14 +72,10 @@ mobs:register_mob("mobs_animal:chicken", {
do_custom = function(self, dtime) do_custom = function(self, dtime)
self.egg_timer = (self.egg_timer or 0) + dtime self.egg_timer = (self.egg_timer or 0) + dtime
if self.egg_timer < 10 then if self.egg_timer < 10 then return end
return
end
self.egg_timer = 0 self.egg_timer = 0
if self.child then if self.child then return end
return
end
local pos = self.object:get_pos() ; if not pos then return end local pos = self.object:get_pos() ; if not pos then return end
@ -99,11 +83,8 @@ mobs:register_mob("mobs_animal:chicken", {
minetest.add_item(pos, "mobs:egg") minetest.add_item(pos, "mobs:egg")
minetest.sound_play("default_place_node_hard", { minetest.sound_play("default_place_node_hard",
pos = pos, {pos = pos, gain = 1.0, max_hear_distance = 5}, true)
gain = 1.0,
max_hear_distance = 5
}, true)
elseif math.random(100) < 3 then elseif math.random(100) < 3 then
minetest.add_item(pos, "mobs:chicken_feather") minetest.add_item(pos, "mobs:chicken_feather")
@ -111,16 +92,16 @@ mobs:register_mob("mobs_animal:chicken", {
end end
}) })
-- where to spawn
local spawn_on = {"default:dirt_with_grass"}
if minetest.get_modpath("ethereal") then
spawn_on = {"ethereal:bamboo_dirt", "ethereal:prairie_dirt"}
end
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
local spawn_on = {"default:dirt_with_grass"}
if minetest.get_modpath("ethereal") then
spawn_on = {"ethereal:bamboo_dirt", "ethereal:prairie_dirt"}
end
mobs:spawn({ mobs:spawn({
name = "mobs_animal:chicken", name = "mobs_animal:chicken",
nodes = spawn_on, nodes = spawn_on,
@ -134,22 +115,24 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:chicken", S("Chicken"), "mobs_chicken_inv.png", 0) mobs:register_egg("mobs_animal:chicken", S("Chicken"), "mobs_chicken_inv.png", 0)
-- compatibility with older mobs mod
mobs:alias_mob("mobs:chicken", "mobs_animal:chicken") -- compatibility mobs:alias_mob("mobs:chicken", "mobs_animal:chicken")
-- egg entity -- egg entity
mobs:register_arrow("mobs_animal:egg_entity", { mobs:register_arrow("mobs_animal:egg_entity", {
visual = "sprite", visual = "sprite",
visual_size = {x=.5, y=.5}, visual_size = {x = .5, y = .5},
textures = {"mobs_chicken_egg.png"}, textures = {"mobs_chicken_egg.png"},
velocity = 6, velocity = 6,
hit_player = function(self, player) hit_player = function(self, player)
player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, { player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = 1} damage_groups = {fleshy = 1}
@ -157,6 +140,7 @@ mobs:register_arrow("mobs_animal:egg_entity", {
end, end,
hit_mob = function(self, player) hit_mob = function(self, player)
player:punch(self.object, 1.0, { player:punch(self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = 1} damage_groups = {fleshy = 1}
@ -165,16 +149,13 @@ mobs:register_arrow("mobs_animal:egg_entity", {
hit_node = function(self, pos, node) hit_node = function(self, pos, node)
if math.random(10) > 1 then if math.random(10) > 1 then return end
return
end
pos.y = pos.y + 1 pos.y = pos.y + 1
local nod = minetest.get_node_or_nil(pos) local nod = minetest.get_node_or_nil(pos)
if not nod if not nod or not minetest.registered_nodes[nod.name]
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then or minetest.registered_nodes[nod.name].walkable == true then
return return
end end
@ -189,22 +170,17 @@ mobs:register_arrow("mobs_animal:egg_entity", {
end end
}) })
-- egg throwing function
-- egg throwing item
local egg_GRAVITY = 9 local egg_GRAVITY = 9
local egg_VELOCITY = 19 local egg_VELOCITY = 19
-- shoot egg
local mobs_shoot_egg = function (item, player, pointed_thing) local mobs_shoot_egg = function (item, player, pointed_thing)
local playerpos = player:get_pos() local playerpos = player:get_pos()
minetest.sound_play("default_place_node_hard", { minetest.sound_play("default_place_node_hard",
pos = playerpos, {pos = playerpos, gain = 1.0, max_hear_distance = 5}, true)
gain = 1.0,
max_hear_distance = 5
})
local obj = minetest.add_entity({ local obj = minetest.add_entity({
x = playerpos.x, x = playerpos.x,
@ -220,16 +196,10 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
ent._is_arrow = true -- tell advanced mob protection this is an arrow ent._is_arrow = true -- tell advanced mob protection this is an arrow
obj:set_velocity({ obj:set_velocity({
x = dir.x * egg_VELOCITY, x = dir.x * egg_VELOCITY, y = dir.y * egg_VELOCITY, z = dir.z * egg_VELOCITY})
y = dir.y * egg_VELOCITY,
z = dir.z * egg_VELOCITY
})
obj:set_acceleration({ obj:set_acceleration({
x = dir.x * -3, x = dir.x * -3, y = -egg_GRAVITY, z = dir.z * -3})
y = -egg_GRAVITY,
z = dir.z * -3
})
-- pass player name to egg for chick ownership -- pass player name to egg for chick ownership
local ent2 = obj:get_luaentity() local ent2 = obj:get_luaentity()
@ -241,8 +211,8 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
return item return item
end end
-- egg -- egg
minetest.register_node(":mobs:egg", { minetest.register_node(":mobs:egg", {
description = S("Chicken Egg"), description = S("Chicken Egg"),
tiles = {"mobs_chicken_egg.png"}, tiles = {"mobs_chicken_egg.png"},
@ -259,16 +229,17 @@ minetest.register_node(":mobs:egg", {
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2} fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
}, },
groups = {food_egg = 1, snappy = 2, dig_immediate = 3}, groups = {food_egg = 1, snappy = 2, dig_immediate = 3},
sounds = mobs.node_sound_defaults(),
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
if placer:is_player() then minetest.set_node(pos, {name = "mobs:egg", param2 = 1})
minetest.set_node(pos, {name = "mobs:egg", param2 = 1})
end
end, end,
on_use = mobs_shoot_egg on_use = mobs_shoot_egg
}) })
-- fried egg and recipe
-- fried egg
minetest.register_craftitem(":mobs:chicken_egg_fried", { minetest.register_craftitem(":mobs:chicken_egg_fried", {
description = S("Fried Egg"), description = S("Fried Egg"),
inventory_image = "mobs_chicken_egg_fried.png", inventory_image = "mobs_chicken_egg_fried.png",
@ -285,6 +256,7 @@ minetest.register_craft({
}) })
-- raw chicken -- raw chicken
minetest.register_craftitem(":mobs:chicken_raw", { minetest.register_craftitem(":mobs:chicken_raw", {
description = S("Raw Chicken"), description = S("Raw Chicken"),
inventory_image = "mobs_chicken_raw.png", inventory_image = "mobs_chicken_raw.png",
@ -294,7 +266,8 @@ minetest.register_craftitem(":mobs:chicken_raw", {
mobs.add_eatable("mobs:chicken_raw", 2) mobs.add_eatable("mobs:chicken_raw", 2)
-- cooked chicken -- cooked chicken and recipe
minetest.register_craftitem(":mobs:chicken_cooked", { minetest.register_craftitem(":mobs:chicken_cooked", {
description = S("Cooked Chicken"), description = S("Cooked Chicken"),
inventory_image = "mobs_chicken_cooked.png", inventory_image = "mobs_chicken_cooked.png",
@ -310,15 +283,12 @@ minetest.register_craft({
output = "mobs:chicken_cooked" output = "mobs:chicken_cooked"
}) })
-- feather -- feather and fuel
minetest.register_craftitem(":mobs:chicken_feather", { minetest.register_craftitem(":mobs:chicken_feather", {
description = S("Feather"), description = S("Feather"),
inventory_image = "mobs_chicken_feather.png", inventory_image = "mobs_chicken_feather.png",
groups = {flammable = 2, feather = 1} groups = {flammable = 2, feather = 1}
}) })
minetest.register_craft({ minetest.register_craft({type = "fuel", recipe = "mobs:chicken_feather", burntime = 1})
type = "fuel",
recipe = "mobs:chicken_feather",
burntime = 1
})

67
cow.lua
View File

@ -1,8 +1,5 @@
-- Translation support
local S = minetest.get_translator("mobs_animal")
-- check for default mod local S = minetest.get_translator("mobs_animal")
local mod_def = minetest.get_modpath("default")
-- Cow by sirrobzeroone -- Cow by sirrobzeroone
@ -24,9 +21,7 @@ mobs:register_mob("mobs_animal:cow", {
{"mobs_cow2.png"} {"mobs_cow2.png"}
}, },
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {random = "mobs_cow"},
random = "mobs_cow",
},
walk_velocity = 1, walk_velocity = 1,
run_velocity = 2, run_velocity = 2,
jump = true, jump = true,
@ -40,25 +35,12 @@ mobs:register_mob("mobs_animal:cow", {
lava_damage = 5, lava_damage = 5,
light_damage = 0, light_damage = 0,
animation = { animation = {
stand_start = 0, stand_start = 0, stand_end = 30, stand_speed = 20,
stand_end = 30, stand1_start = 35, stand1_end = 75, stand1_speed = 20,
stand_speed = 20, walk_start = 85, walk_end = 114, walk_speed = 20,
stand1_start = 35, run_start = 120, run_end = 140, run_speed = 30,
stand1_end = 75, punch_start = 145, punch_end = 160, punch_speed = 20,
stand1_speed = 20, die_start = 165, die_end = 185, die_speed = 10, die_loop = false
walk_start = 85,
walk_end = 114,
walk_speed = 20,
run_start = 120,
run_end = 140,
run_speed = 30,
punch_start = 145,
punch_end = 160,
punch_speed = 20,
die_start = 165,
die_end = 185,
die_speed = 10,
die_loop = false
}, },
follow = { follow = {
"farming:wheat", "default:grass_1", "farming:barley", "farming:wheat", "default:grass_1", "farming:barley",
@ -79,9 +61,7 @@ mobs:register_mob("mobs_animal:cow", {
if mobs:feed_tame(self, clicker, 8, true, true) then if mobs:feed_tame(self, clicker, 8, true, true) then
-- if fed 7x wheat or grass then cow can be milked again -- if fed 7x wheat or grass then cow can be milked again
if self.food and self.food > 6 then if self.food and self.food > 6 then self.gotten = false end
self.gotten = false
end
return return
end end
@ -98,10 +78,7 @@ mobs:register_mob("mobs_animal:cow", {
or item == "wooden_bucket:bucket_wood_empty" or item == "wooden_bucket:bucket_wood_empty"
or item == "bucket_wooden:bucket_empty" then or item == "bucket_wooden:bucket_empty" then
--if self.gotten == true if self.child == true then return end
if self.child == true then
return
end
if self.gotten == true then if self.gotten == true then
@ -143,14 +120,14 @@ mobs:register_mob("mobs_animal:cow", {
self.food = (self.food or 0) + 1 self.food = (self.food or 0) + 1
-- if cow replaces 8x grass then it can be milked again if self.food >= 8 then -- replace 8x grass and can be milked again
if self.food >= 8 then
self.food = 0 self.food = 0
self.gotten = false self.gotten = false
end end
end end
}) })
-- where to spawn
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
@ -167,14 +144,16 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:cow", S("Cow"), "mobs_cow_inv.png") mobs:register_egg("mobs_animal:cow", S("Cow"), "mobs_cow_inv.png")
-- old mobs mod compatibility
mobs:alias_mob("mobs:cow", "mobs_animal:cow") -- compatibility mobs:alias_mob("mobs:cow", "mobs_animal:cow")
-- bucket of milk -- bucket of milk
minetest.register_craftitem(":mobs:bucket_milk", { minetest.register_craftitem(":mobs:bucket_milk", {
description = S("Bucket of Milk"), description = S("Bucket of Milk"),
inventory_image = "mobs_bucket_milk.png", inventory_image = "mobs_bucket_milk.png",
@ -185,7 +164,7 @@ minetest.register_craftitem(":mobs:bucket_milk", {
mobs.add_eatable("mobs:bucket_milk", 8) mobs.add_eatable("mobs:bucket_milk", 8)
-- glass of milk -- glass of milk and recipes
minetest.register_craftitem(":mobs:glass_milk", { minetest.register_craftitem(":mobs:glass_milk", {
description = S("Glass of Milk"), description = S("Glass of Milk"),
inventory_image = "mobs_glass_milk.png", inventory_image = "mobs_glass_milk.png",
@ -217,8 +196,8 @@ minetest.register_craft({
} }
}) })
-- butter and recipe
-- butter
minetest.register_craftitem(":mobs:butter", { minetest.register_craftitem(":mobs:butter", {
description = S("Butter"), description = S("Butter"),
inventory_image = "mobs_butter.png", inventory_image = "mobs_butter.png",
@ -240,7 +219,8 @@ minetest.register_craft({
replacements = {{"mobs:bucket_milk", "bucket:bucket_empty"}} replacements = {{"mobs:bucket_milk", "bucket:bucket_empty"}}
}) })
-- cheese wedge -- cheese wedge and recipe
minetest.register_craftitem(":mobs:cheese", { minetest.register_craftitem(":mobs:cheese", {
description = S("Cheese"), description = S("Cheese"),
inventory_image = "mobs_cheese.png", inventory_image = "mobs_cheese.png",
@ -258,13 +238,14 @@ minetest.register_craft({
replacements = {{"mobs:bucket_milk", "bucket:bucket_empty"}} replacements = {{"mobs:bucket_milk", "bucket:bucket_empty"}}
}) })
-- cheese block -- cheese block and recipe
minetest.register_node(":mobs:cheeseblock", { minetest.register_node(":mobs:cheeseblock", {
description = S("Cheese Block"), description = S("Cheese Block"),
tiles = {"mobs_cheeseblock.png"}, tiles = {"mobs_cheeseblock.png"},
is_ground_content = false, is_ground_content = false,
groups = {oddly_breakable_by_hand = 3}, groups = {oddly_breakable_by_hand = 3},
sounds = mod_def and default.node_sound_dirt_defaults() sounds = mobs.node_sound_dirt_defaults()
}) })
minetest.register_craft({ minetest.register_craft({
@ -281,8 +262,8 @@ minetest.register_craft({
recipe = {{"mobs:cheeseblock"}} recipe = {{"mobs:cheeseblock"}}
}) })
-- check for either of the wood bucket mods and add compatibility -- check for either of the wood bucket mods and add compatibility
local wb = minetest.get_modpath("wooden_bucket") local wb = minetest.get_modpath("wooden_bucket")
local bw = minetest.get_modpath("bucket_wooden") local bw = minetest.get_modpath("bucket_wooden")

View File

@ -1,9 +1,11 @@
-- translation and mod path
local S = minetest.get_translator("mobs_animal")
local path = minetest.get_modpath(minetest.get_current_modname()) .. "/" local path = minetest.get_modpath(minetest.get_current_modname()) .. "/"
-- Translation support
local S = minetest.get_translator("mobs_animal")
-- Check for custom mob spawn file -- Check for custom mob spawn file
local input = io.open(path .. "spawn.lua", "r") local input = io.open(path .. "spawn.lua", "r")
if input then if input then
@ -12,8 +14,8 @@ if input then
input = nil input = nil
end end
-- helper function -- helper function
local function ddoo(mob) local function ddoo(mob)
if minetest.settings:get_bool("mobs_animal." .. mob) == false then if minetest.settings:get_bool("mobs_animal." .. mob) == false then
@ -25,6 +27,7 @@ local function ddoo(mob)
end end
-- Animals -- Animals
ddoo("chicken") -- JKmurray ddoo("chicken") -- JKmurray
ddoo("cow") -- KrupnoPavel ddoo("cow") -- KrupnoPavel
ddoo("rat") -- PilzAdam ddoo("rat") -- PilzAdam
@ -36,17 +39,16 @@ ddoo("kitten") -- Jordach/BFD
ddoo("penguin") -- D00Med ddoo("penguin") -- D00Med
ddoo("panda") -- AspireMint ddoo("panda") -- AspireMint
-- Load custom spawning if found
-- Load custom spawning
if mobs.custom_spawn_animal then if mobs.custom_spawn_animal then
dofile(path .. "spawn.lua") dofile(path .. "spawn.lua")
end end
-- Lucky Blocks -- Lucky Blocks
if minetest.get_modpath("lucky_block") then if minetest.get_modpath("lucky_block") then
dofile(path .. "lucky_block.lua") dofile(path .. "lucky_block.lua")
end end
print ("[MOD] Mobs Animal loaded") print ("[MOD] Mobs Animal loaded")

View File

@ -1,7 +1,10 @@
-- Translation support
local S = minetest.get_translator("mobs_animal")
local hairball = minetest.settings:get("mobs_hairball") -- translation and hairball setting
local S = minetest.get_translator("mobs_animal")
local hairball = minetest.settings:get_bool("mobs_animal.hairball") ~= false
-- custom kitty types
local kitten_types = { local kitten_types = {
@ -37,9 +40,7 @@ mobs:register_mob("mobs_animal:kitten", {
{"mobs_kitten_sandy.png"} {"mobs_kitten_sandy.png"}
}, },
makes_footstep_sound = false, makes_footstep_sound = false,
sounds = { sounds = {random = "mobs_kitten"},
random = "mobs_kitten"
},
walk_velocity = 0.6, walk_velocity = 0.6,
walk_chance = 15, walk_chance = 15,
run_velocity = 2, run_velocity = 2,
@ -53,12 +54,9 @@ mobs:register_mob("mobs_animal:kitten", {
fear_height = 3, fear_height = 3,
animation = { animation = {
speed_normal = 42, speed_normal = 42,
stand_start = 97, stand_start = 97, stand_end = 192,
stand_end = 192, walk_start = 0, walk_end = 96,
walk_start = 0, stoodup_start = 0, stoodup_end = 0,
walk_end = 96,
stoodup_start = 0,
stoodup_end = 0,
}, },
follow = { follow = {
"mobs_animal:rat", "group:food_fish_raw", "mobs_animal:rat", "group:food_fish_raw",
@ -111,19 +109,13 @@ mobs:register_mob("mobs_animal:kitten", {
do_custom = function(self, dtime) do_custom = function(self, dtime)
if hairball == "false" then if not hairball then return end
return
end
self.hairball_timer = (self.hairball_timer or 0) + dtime self.hairball_timer = (self.hairball_timer or 0) + dtime
if self.hairball_timer < 10 then if self.hairball_timer < 10 then return end
return
end
self.hairball_timer = 0 self.hairball_timer = 0
if self.child or math.random(250) > 1 then if self.child or math.random(250) > 1 then return end
return
end
local pos = self.object:get_pos() local pos = self.object:get_pos()
@ -134,15 +126,16 @@ mobs:register_mob("mobs_animal:kitten", {
end end
}) })
-- where to spawn
local spawn_on = "default:dirt_with_grass"
if minetest.get_modpath("ethereal") then
spawn_on = "ethereal:grove_dirt"
end
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
local spawn_on = "default:dirt_with_grass"
if minetest.get_modpath("ethereal") then
spawn_on = "ethereal:grove_dirt"
end
mobs:spawn({ mobs:spawn({
name = "mobs_animal:kitten", name = "mobs_animal:kitten",
nodes = {spawn_on}, nodes = {spawn_on},
@ -156,12 +149,15 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:kitten", S("Kitten"), "mobs_kitten_inv.png", 0) mobs:register_egg("mobs_animal:kitten", S("Kitten"), "mobs_kitten_inv.png", 0)
-- compatibility with old mobs mod
mobs:alias_mob("mobs:kitten", "mobs_animal:kitten") -- compatibility mobs:alias_mob("mobs:kitten", "mobs_animal:kitten")
-- hairball and items
local hairball_items = { local hairball_items = {
"default:stick", "default:coal_lump", "default:dry_shrub", "flowers:rose", "default:stick", "default:coal_lump", "default:dry_shrub", "flowers:rose",
@ -177,6 +173,7 @@ local hairball_items = {
minetest.register_craftitem(":mobs:hairball", { minetest.register_craftitem(":mobs:hairball", {
description = S("Hairball"), description = S("Hairball"),
inventory_image = "mobs_hairball.png", inventory_image = "mobs_hairball.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local pos = user:get_pos() local pos = user:get_pos()
@ -184,8 +181,7 @@ minetest.register_craftitem(":mobs:hairball", {
local newpos = {x = pos.x + dir.x, y = pos.y + dir.y + 1.5, z = pos.z + dir.z} local newpos = {x = pos.x + dir.x, y = pos.y + dir.y + 1.5, z = pos.z + dir.z}
local item = hairball_items[math.random(1, #hairball_items)] local item = hairball_items[math.random(1, #hairball_items)]
if item ~= "" if item ~= "" and minetest.registered_items[item] then
and minetest.registered_items[item] then
minetest.add_item(newpos, {name = item}) minetest.add_item(newpos, {name = item})
end end

View File

@ -1,3 +1,6 @@
-- add lucky blocks
lucky_block:add_blocks({ lucky_block:add_blocks({
{"spw", "mobs:sheep", 5}, {"spw", "mobs:sheep", 5},
{"spw", "mobs:rat", 5}, {"spw", "mobs:rat", 5},
@ -20,6 +23,8 @@ lucky_block:add_blocks({
{"dro", {"mobs:glass_milk"}, 5} {"dro", {"mobs:glass_milk"}, 5}
}) })
-- if nyancat found add special block
if minetest.registered_nodes["default:nyancat"] then if minetest.registered_nodes["default:nyancat"] then
lucky_block:add_blocks({ lucky_block:add_blocks({

View File

@ -1,10 +1,10 @@
-- Translation support
local S = minetest.get_translator("mobs_animal") local S = minetest.get_translator("mobs_animal")
-- Panda by AspireMint (CC BY-SA 3.0) -- Panda by AspireMint (CC BY-SA 3.0)
mobs:register_mob("mobs_animal:panda", { mobs:register_mob("mobs_animal:panda", {
stepheight = 0.6, stepheight = 0.6,
type = "animal", type = "animal",
passive = false, passive = false,
attack_type = "dogfight", attack_type = "dogfight",
@ -19,9 +19,7 @@ stepheight = 0.6,
collisionbox = {-0.4, -0.45, -0.4, 0.4, 0.45, 0.4}, collisionbox = {-0.4, -0.45, -0.4, 0.4, 0.45, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_panda.b3d", mesh = "mobs_panda.b3d",
textures = { textures = {{"mobs_panda.png"}},
{"mobs_panda.png"}
},
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {
random = "mobs_panda", random = "mobs_panda",
@ -43,21 +41,13 @@ stepheight = 0.6,
fear_height = 6, fear_height = 6,
animation = { animation = {
speed_normal = 15, speed_normal = 15,
stand_start = 130, stand_start = 130, stand_end = 270,
stand_end = 270, stand1_start = 0, stand1_end = 0, -- rest
stand1_start = 0, stand2_start = 1, stand2_end = 1, -- covers eyes
stand1_end = 0, stand3_start = 2, stand3_end = 2, -- surprised
stand2_start = 1, walk_start = 10, walk_end = 70,
stand2_end = 1, run_start = 10, run_end = 70,
stand3_start = 2, punch_start = 80, punch_end = 120
stand3_end = 2,
walk_start = 10,
walk_end = 70,
run_start = 10,
run_end = 70,
punch_start = 80,
punch_end = 120,
-- 0 = rest, 1 = hiding (covers eyes), 2 = surprised
}, },
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
@ -68,6 +58,7 @@ stepheight = 0.6,
end end
}) })
-- where to spawn (ethereal bamboo biome only)
if minetest.get_modpath("ethereal") and not mobs.custom_spawn_animal then if minetest.get_modpath("ethereal") and not mobs.custom_spawn_animal then
@ -84,5 +75,6 @@ if minetest.get_modpath("ethereal") and not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:panda", S("Panda"), "mobs_panda_inv.png") mobs:register_egg("mobs_animal:panda", S("Panda"), "mobs_panda_inv.png")

View File

@ -1,4 +1,4 @@
-- Translation support
local S = minetest.get_translator("mobs_animal") local S = minetest.get_translator("mobs_animal")
-- Penguin by D00Med -- Penguin by D00Med
@ -15,9 +15,7 @@ stepheight = 0.6,
visual = "mesh", visual = "mesh",
mesh = "mobs_penguin.b3d", mesh = "mobs_penguin.b3d",
visual_size = {x = 0.25, y = 0.25}, visual_size = {x = 0.25, y = 0.25},
textures = { textures = {{"mobs_penguin.png"}},
{"mobs_penguin.png"}
},
sounds = {}, sounds = {},
makes_footstep_sound = true, makes_footstep_sound = true,
walk_velocity = 1, walk_velocity = 1,
@ -34,12 +32,9 @@ stepheight = 0.6,
fear_height = 2, fear_height = 2,
animation = { animation = {
speed_normal = 15, speed_normal = 15,
stand_start = 1, stand_start = 1, stand_end = 20,
stand_end = 20, walk_start = 25, walk_end = 45,
walk_start = 25, fly_start = 75, fly_end = 95 -- swim animation
walk_end = 45,
fly_start = 75, -- swim animation
fly_end = 95
-- 50-70 is slide/water idle -- 50-70 is slide/water idle
}, },
fly_in = {"default:water_source", "default:water_flowing"}, fly_in = {"default:water_source", "default:water_flowing"},
@ -59,6 +54,7 @@ stepheight = 0.6,
end end
}) })
-- where to spawn
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
@ -74,5 +70,6 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:penguin", S("Penguin"), "mobs_penguin_inv.png") mobs:register_egg("mobs_animal:penguin", S("Penguin"), "mobs_penguin_inv.png")

17
rat.lua
View File

@ -1,10 +1,10 @@
-- Translation support
local S = minetest.get_translator("mobs_animal") local S = minetest.get_translator("mobs_animal")
-- Rat by KPavel and PilzAdam (B3D model by sirrobzeroone) -- Rat by KPavel and PilzAdam (B3D model by sirrobzeroone)
mobs:register_mob("mobs_animal:rat", { mobs:register_mob("mobs_animal:rat", {
stepheight = 0.6, stepheight = 0.6,
type = "animal", type = "animal",
passive = true, passive = true,
hp_min = 1, hp_min = 1,
@ -18,9 +18,7 @@ stepheight = 0.6,
{"mobs_rat2.png"} {"mobs_rat2.png"}
}, },
makes_footstep_sound = false, makes_footstep_sound = false,
sounds = { sounds = {random = "mobs_rat"},
random = "mobs_rat"
},
walk_velocity = 1, walk_velocity = 1,
run_velocity = 2, run_velocity = 2,
runaway = true, runaway = true,
@ -59,8 +57,8 @@ stepheight = 0.6,
]] ]]
}) })
-- example on_spawn function -- example on_spawn function
local function rat_spawn(self, pos) local function rat_spawn(self, pos)
self = self:get_luaentity() self = self:get_luaentity()
print (self.name, pos.x, pos.y, pos.z) print (self.name, pos.x, pos.y, pos.z)
@ -68,6 +66,7 @@ local function rat_spawn(self, pos)
self.health = 100 self.health = 100
end end
-- where to spawn
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
@ -83,14 +82,16 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg
mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inv.png") mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inv.png")
-- compatibility with older mobs mod
mobs:alias_mob("mobs:rat", "mobs_animal:rat") -- compatibility mobs:alias_mob("mobs:rat", "mobs_animal:rat")
-- cooked rat, yummy! -- cooked rat, yummy!
minetest.register_craftitem(":mobs:rat_cooked", { minetest.register_craftitem(":mobs:rat_cooked", {
description = S("Cooked Rat"), description = S("Cooked Rat"),
inventory_image = "mobs_cooked_rat.png", inventory_image = "mobs_cooked_rat.png",

View File

@ -17,7 +17,7 @@ Wanders around eating grass/wheat and can be right-clicked with empty bucket to
--- ---
### Kitten ### Kitten
Found on green grass these cute cats walk around and can be picked up and placed in inventory as pets or right-clicked with 4x live rats or raw fish (found in ethereal) and tamed. They can sometimes leave you little gifts of a hairball. Found on green grass these cute cats walk around and can be picked up and placed in inventory as pets or right-clicked with 4x live rats or raw fish (found in ethereal) and tamed. They can sometimes leave you little gifts of a hairball, remember to check just incase it contains an item.
--- ---
### Rat ### Rat

View File

@ -8,3 +8,4 @@ mobs_animal.penguin (Enable Penguin) bool true
mobs_animal.rat (Enable Rat) bool true mobs_animal.rat (Enable Rat) bool true
mobs_animal.sheep (Enable Sheep) bool true mobs_animal.sheep (Enable Sheep) bool true
mobs_animal.warthog (Enable Warthog) bool true mobs_animal.warthog (Enable Warthog) bool true
mobs_animal.hairball (Enable Kitten Hairball drops) bool true

View File

@ -1,7 +1,11 @@
-- Translation support
local S = minetest.get_translator("mobs_animal")
-- translation and localize function
local S = minetest.get_translator("mobs_animal")
local random = math.random local random = math.random
-- sheep colour table
local all_colours = { local all_colours = {
{"black", S("Black"), "#212121b0"}, -- referenced down in mobs:spawn {"black", S("Black"), "#212121b0"}, -- referenced down in mobs:spawn
{"blue", S("Blue"), "#015dbb70"}, {"blue", S("Blue"), "#015dbb70"},
@ -20,7 +24,6 @@ local all_colours = {
{"yellow", S("Yellow"), "#fff80070"} {"yellow", S("Yellow"), "#fff80070"}
} }
-- Sheep by PilzAdam/K Pavel, texture converted to minetest by AMMOnym from Summerfield pack -- Sheep by PilzAdam/K Pavel, texture converted to minetest by AMMOnym from Summerfield pack
for _, col in ipairs(all_colours) do for _, col in ipairs(all_colours) do
@ -87,9 +90,7 @@ for _, col in ipairs(all_colours) do
}, },
gotten_texture = {"mobs_sheep_base.png^mobs_sheep_shaved.png"}, gotten_texture = {"mobs_sheep_base.png^mobs_sheep_shaved.png"},
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {random = "mobs_sheep"},
random = "mobs_sheep"
},
walk_velocity = 1, walk_velocity = 1,
run_velocity = 2, run_velocity = 2,
runaway = true, runaway = true,
@ -101,17 +102,13 @@ for _, col in ipairs(all_colours) do
lava_damage = 5, lava_damage = 5,
light_damage = 0, light_damage = 0,
animation = { animation = {
speed_normal = 15, speed_normal = 15, speed_run = 15,
speed_run = 15, stand_start = 0, stand_end = 80,
stand_start = 0, walk_start = 81, walk_end = 100,
stand_end = 80, -- no death animation so we'll re-use 2 standing frames at a speed of 1 fps
walk_start = 81, -- and have mob rotate while dying.
walk_end = 100, die_start = 1, die_end = 2, die_speed = 1,
die_start = 1, -- we dont have a specific death animation so we will die_loop = false, die_rotate = true
die_end = 2, -- re-use 2 standing frames at a speed of 1 fps and
die_speed = 1, -- have mob rotate when dying.
die_loop = false,
die_rotate = true
}, },
follow = { follow = {
"farming:wheat", "default:grass_1", "farming:barley", "farming:wheat", "default:grass_1", "farming:barley",
@ -183,24 +180,17 @@ for _, col in ipairs(all_colours) do
mob:set_properties({ mob:set_properties({
textures = {textures}, textures = {textures},
visual_size = { visual_size = {
x = parent1.base_size.x * .5, x = parent1.base_size.x * .5, y = parent1.base_size.y * .5
y = parent1.base_size.y * .5
}, },
collisionbox = { collisionbox = {
parent1.base_colbox[1] * .5, parent1.base_colbox[1] * .5, parent1.base_colbox[2] * .5,
parent1.base_colbox[2] * .5, parent1.base_colbox[3] * .5, parent1.base_colbox[4] * .5,
parent1.base_colbox[3] * .5, parent1.base_colbox[5] * .5, parent1.base_colbox[6] * .5
parent1.base_colbox[4] * .5,
parent1.base_colbox[5] * .5,
parent1.base_colbox[6] * .5
}, },
selectionbox = { selectionbox = {
parent1.base_selbox[1] * .5, parent1.base_selbox[1] * .5, parent1.base_selbox[2] * .5,
parent1.base_selbox[2] * .5, parent1.base_selbox[3] * .5, parent1.base_selbox[4] * .5,
parent1.base_selbox[3] * .5, parent1.base_selbox[5] * .5, parent1.base_selbox[6] * .5
parent1.base_selbox[4] * .5,
parent1.base_selbox[5] * .5,
parent1.base_selbox[6] * .5
} }
}) })
@ -279,10 +269,8 @@ for _, col in ipairs(all_colours) do
-- are we giving a haircut> -- are we giving a haircut>
if itemname == "mobs:shears" then if itemname == "mobs:shears" then
if self.gotten ~= false if self.gotten ~= false or self.child ~= false
or self.child ~= false or name ~= self.owner or not minetest.get_modpath("wool") then
or name ~= self.owner
or not minetest.get_modpath("wool") then
return return
end end
@ -297,10 +285,7 @@ for _, col in ipairs(all_colours) do
if obj then if obj then
obj:set_velocity({ obj:set_velocity({
x = random(-1, 1), x = random(-1, 1), y = 5, z = random(-1, 1)})
y = 5,
z = random(-1, 1)
})
end end
item:add_wear(650) -- 100 uses item:add_wear(650) -- 100 uses
@ -318,18 +303,15 @@ for _, col in ipairs(all_colours) do
-- are we coloring? -- are we coloring?
if itemname:find("dye:") then if itemname:find("dye:") then
if self.gotten == false if self.gotten == false and self.child == false
and self.child == false and self.tamed == true and name == self.owner then
and self.tamed == true
and name == self.owner then
local colr = string.split(itemname, ":")[2] local colr = string.split(itemname, ":")[2]
for _,c in pairs(all_colours) do for _,c in pairs(all_colours) do
-- only dye if colour option available and sheep not same colour -- only dye if colour option available and sheep not same colour
if c[1] == colr if c[1] == colr and self.name ~= "mobs_animal:sheep_" .. colr then
and self.name ~= "mobs_animal:sheep_" .. colr then
local pos = self.object:get_pos() local pos = self.object:get_pos()
@ -393,6 +375,7 @@ for _, col in ipairs(all_colours) do
mobs:alias_mob("mobs:sheep_" .. col[1], "mobs_animal:sheep_" .. col[1]) mobs:alias_mob("mobs:sheep_" .. col[1], "mobs_animal:sheep_" .. col[1])
end end
-- where to spawn
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
@ -457,8 +440,8 @@ if not mobs.custom_spawn_animal then
local entity = mobs:add_mob(pos, local entity = mobs:add_mob(pos,
{name = "mobs_animal:sheep_" .. types, child = lamb}) {name = "mobs_animal:sheep_" .. types, child = lamb})
-- nil check -- nil check
if not entity then return end if not entity then return end
if not lamb then if not lamb then
-- Set horns attribute, lower height will be rarer. -- Set horns attribute, lower height will be rarer.
@ -510,10 +493,12 @@ if not entity then return end
}) })
end end
-- compatibility with older mobs mod
mobs:alias_mob("mobs:sheep", "mobs_animal:sheep_white") -- compatibility mobs:alias_mob("mobs:sheep", "mobs_animal:sheep_white")
-- raw mutton -- raw mutton
minetest.register_craftitem(":mobs:mutton_raw", { minetest.register_craftitem(":mobs:mutton_raw", {
description = S("Raw Mutton"), description = S("Raw Mutton"),
inventory_image = "mobs_mutton_raw.png", inventory_image = "mobs_mutton_raw.png",
@ -523,7 +508,8 @@ minetest.register_craftitem(":mobs:mutton_raw", {
mobs.add_eatable("mobs:mutton_raw", 2) mobs.add_eatable("mobs:mutton_raw", 2)
-- cooked mutton -- cooked mutton and recipe
minetest.register_craftitem(":mobs:mutton_cooked", { minetest.register_craftitem(":mobs:mutton_cooked", {
description = S("Cooked Mutton"), description = S("Cooked Mutton"),
inventory_image = "mobs_mutton_cooked.png", inventory_image = "mobs_mutton_cooked.png",

View File

@ -1,4 +1,4 @@
-- Translation support
local S = minetest.get_translator("mobs_animal") local S = minetest.get_translator("mobs_animal")
-- Warthog originally by KrupnoPavel, B3D model by sirrobzeroone -- Warthog originally by KrupnoPavel, B3D model by sirrobzeroone
@ -19,9 +19,7 @@ mobs:register_mob("mobs_animal:pumba", {
collisionbox = {-0.4, -0.01, -0.4, 0.4, 0.95, 0.4}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 0.95, 0.4},
visual = "mesh", visual = "mesh",
mesh = "mobs_pumba.b3d", mesh = "mobs_pumba.b3d",
textures = { textures = {{"mobs_pumba.png"}},
{"mobs_pumba.png"}
},
makes_footstep_sound = true, makes_footstep_sound = true,
sounds = { sounds = {
random = "mobs_pig", random = "mobs_pig",
@ -43,18 +41,12 @@ mobs:register_mob("mobs_animal:pumba", {
fear_height = 2, fear_height = 2,
animation = { animation = {
speed_normal = 15, speed_normal = 15,
stand_start = 25, stand_start = 25, stand_end = 55,
stand_end = 55, walk_start = 70, walk_end = 100,
walk_start = 70, punch_start = 70, punch_end = 100,
walk_end = 100, -- no specific dying animation, so use 2 frames at 1fps and rotate
punch_start = 70, die_start = 1, die_end = 2, die_speed = 1,
punch_end = 100, die_loop = false, die_rotate = true
die_start = 1, -- we dont have a specific death animation so we will
die_end = 2, -- re-use 2 standing frames at a speed of 1 fps and
die_speed = 1, -- have mob rotate when dying.
die_loop = false,
die_rotate = true
}, },
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
@ -65,22 +57,18 @@ mobs:register_mob("mobs_animal:pumba", {
end end
}) })
-- where to spawn
local spawn_on = {"default:dirt_with_grass"}
local spawn_by = {"group:grass"}
if minetest.get_mapgen_setting("mg_name") ~= "v6" then
spawn_on = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"}
spawn_by = {"group:dry_grass"}
end
if minetest.get_modpath("ethereal") then
spawn_on = {"ethereal:mushroom_dirt"}
spawn_by = {"flowers:mushroom_brown", "flowers:mushroom_red"}
end
if not mobs.custom_spawn_animal then if not mobs.custom_spawn_animal then
local spawn_on = {"default:dirt_with_grass", "default:dry_dirt_with_dry_grass"}
local spawn_by = {"group:grass"}
if minetest.get_modpath("ethereal") then
spawn_on = {"ethereal:mushroom_dirt"}
spawn_by = {"flowers:mushroom_brown", "flowers:mushroom_red"}
end
mobs:spawn({ mobs:spawn({
name = "mobs_animal:pumba", name = "mobs_animal:pumba",
nodes = spawn_on, nodes = spawn_on,
@ -94,15 +82,16 @@ if not mobs.custom_spawn_animal then
}) })
end end
-- spawn egg -- spawn egg
mobs:register_egg("mobs_animal:pumba", S("Warthog"), "mobs_pumba_inv.png") mobs:register_egg("mobs_animal:pumba", S("Warthog"), "mobs_pumba_inv.png")
-- old mobs mod compatibility
mobs:alias_mob("mobs:pumba", "mobs_animal:pumba") -- compatibility mobs:alias_mob("mobs:pumba", "mobs_animal:pumba")
-- raw porkchop -- raw porkchop
minetest.register_craftitem(":mobs:pork_raw", { minetest.register_craftitem(":mobs:pork_raw", {
description = S("Raw Porkchop"), description = S("Raw Porkchop"),
inventory_image = "mobs_pork_raw.png", inventory_image = "mobs_pork_raw.png",
@ -112,7 +101,8 @@ minetest.register_craftitem(":mobs:pork_raw", {
mobs.add_eatable("mobs:pork_raw", 4) mobs.add_eatable("mobs:pork_raw", 4)
-- cooked porkchop -- cooked porkchop and recipe
minetest.register_craftitem(":mobs:pork_cooked", { minetest.register_craftitem(":mobs:pork_cooked", {
description = S("Cooked Porkchop"), description = S("Cooked Porkchop"),
inventory_image = "mobs_pork_cooked.png", inventory_image = "mobs_pork_cooked.png",