Add setting for sheep (mesh,sprite,disabled)

This commit is contained in:
Hildigerr Vergaray 2020-04-18 03:24:33 -07:00
parent 9ba3c5e94f
commit 8b05b80454
4 changed files with 17 additions and 10 deletions

View File

@ -17,6 +17,7 @@ Upstream contributions have been included from:
- **Only Peaceful Mobs** if you just want animals, *disabled* by default
- **Drop Litter** if mobs should drop dropps when dying naturally, *disabled* by default
- **Meat Rots** if raw meat should rot periodically, *disabled* by default
- **Sheep** can be drawn with a default 3D *mesh*, a 2D sprite, or be disabled.
## The Mobs ##

View File

@ -1,4 +1,5 @@
local USE_SPRITES = minetest.settings:get_bool("mobs.use_sprites", false)
local sheep_setting = minetest.settings:get("mobs.sheep") or "mesh"
local USE_SPRITES = sheep_setting ~= "mesh"
mobs:register_mob("sheep", {
type = "animal",
@ -88,4 +89,4 @@ mobs:register_mob("sheep", {
})
end
end,
})
}, sheep_setting == "disabled")

View File

@ -1,6 +1,6 @@
mobs = {spawning_mobs = {}}
mobs = {}
function mobs:register_mob(name, def)
function mobs:register_mob(name, def, disabled)
name = "mobs:"..name
minetest.register_entity(":"..name, {
type = def.type,
@ -133,7 +133,7 @@ function mobs:register_mob(name, def)
end
end,
on_step = function(self, dtime)
on_step = not disabled and function(self, dtime)
local pos = self.object:get_pos()
local n = minetest.get_node(pos)
if self.type == "monster" and minetest.settings:get_bool("mobs.only_peaceful_mobs", false) then
@ -374,6 +374,9 @@ function mobs:register_mob(name, def)
end
end
end
end or function (self, dtime)
minetest.log("action", "Removed disabled "..name.." at "..minetest.pos_to_string(self.object:get_pos()))
self.object:remove()
end,
on_activate = function(self, staticdata, dtime_s)
@ -450,10 +453,9 @@ function mobs:register_mob(name, def)
end
end
end,
})
mobs.spawning_mobs[name] = true
if not disabled then
minetest.register_abm({
nodenames = def.spawning_nodes,
neighbors = {"air"},
@ -463,9 +465,6 @@ function mobs:register_mob(name, def)
if active_object_count_wider > def.max_spawn_count then
return
end
if not mobs.spawning_mobs[name] then
return
end
pos.y = pos.y+1
if not minetest.get_node_light(pos) then
return
@ -496,6 +495,7 @@ function mobs:register_mob(name, def)
minetest.add_entity(pos, name)
end
})
end
end
function mobs:register_arrow(name, def)

View File

@ -14,3 +14,8 @@ mobs.drop_litter (Drop Litter) bool false
# Meat will rot if not cooked or refridgerated
mobs.meat_rots (Meat Rots) bool false
[animals]
# Sheep can be drawn with a 3D mesh, a 2D sprite, or be disabled.
mobs.sheep (Sheep) enum mesh mesh,sprite,disabled