diff --git a/README.txt b/README.txt index 055f141..c868758 100644 --- a/README.txt +++ b/README.txt @@ -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 :) diff --git a/api.lua b/api.lua index 1689f4c..571728f 100644 --- a/api.lua +++ b/api.lua @@ -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 diff --git a/cow.lua b/cow.lua index 95996a8..a9c5ae6 100644 --- a/cow.lua +++ b/cow.lua @@ -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 diff --git a/init.lua b/init.lua index 56837fb..795a6ff 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ --- Mob Api (15th Oct 2014) +-- Mob Api (10th Dec 2014) dofile(minetest.get_modpath("mobs").."/api.lua")