Added switch to disable mobs in protected areas

This commit is contained in:
tenplus1 2014-12-10 10:08:07 +00:00
parent 9269057bd7
commit b59dd435d8
4 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,7 @@ This mod contains the following additions:
Changelog:
0.7 - mob.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes
0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block
0.5 - Mobs now float in water, die from falling, and some code improvements
0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :)

View File

@ -1,5 +1,7 @@
mobs = {}
mobs.mod = "redo"
mobs.protected = 0 -- Set to 1 if you do not wish mobs to spawn in protected areas (default: 0)
function mobs:register_mob(name, def)
minetest.register_entity(name, {
name = name,
@ -792,7 +794,12 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
if not mobs.spawning_mobs[name] then
return
end
-- Check if protected area using bogus name so mobs will not spawn
if mobs.protected == 1 and minetest.is_protected(pos, "-") then
return
end
pos.y = pos.y+1
if not minetest.get_node_light(pos) then
return

View File

@ -35,7 +35,7 @@ mobs:register_mob("mobs:cow", {
},
-- right-click cow with empty bucket to get milk, then feed 8 wheat to replenish milk
on_rightclick = function(self, clicker)
tool = clicker:get_wielded_item()
local tool = clicker:get_wielded_item()
if tool:get_name() == "bucket:bucket_empty" then
if self.milked then
do return end

View File

@ -1,4 +1,4 @@
-- Mob Api (15th Oct 2014)
-- Mob Api (10th Dec 2014)
dofile(minetest.get_modpath("mobs").."/api.lua")