diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2018-06-04 16:51:11 +0100 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2018-06-04 16:51:11 +0100 |
commit | 4a5563854d1c2b3e17139e9e2117f2aad3de63f5 (patch) | |
tree | 87325113ecd781e58983d068ac7d857d2dfd5080 | |
parent | c23d58f1ec694d6cded68bd5db18e603a83ecb61 (diff) |
re-organise spawning checks (lightest first)
-rw-r--r-- | api.lua | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -3,7 +3,7 @@ mobs = {} mobs.mod = "redo" -mobs.version = "20180603" +mobs.version = "20180604" -- Intllib @@ -3254,24 +3254,6 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, -- spawn above node pos.y = pos.y + 1 - -- only spawn away from player - local objs = minetest.get_objects_inside_radius(pos, 10) - - for n = 1, #objs do - - if objs[n]:is_player() then ---print ("--- player too close", name) - return - end - end - - -- mobs cannot spawn in protected areas when enabled - if not spawn_protected - and minetest.is_protected(pos, "") then ---print ("--- inside protected area", name) - return - end - -- are we spawning within height limits? if pos.y > max_height or pos.y < min_height then @@ -3288,6 +3270,24 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, return end + -- mobs cannot spawn in protected areas when enabled + if not spawn_protected + and minetest.is_protected(pos, "") then +--print ("--- inside protected area", name) + return + end + + -- only spawn away from player + local objs = minetest.get_objects_inside_radius(pos, 10) + + for n = 1, #objs do + + if objs[n]:is_player() then +--print ("--- player too close", name) + return + end + end + -- do we have enough height clearance to spawn mob? local ent = minetest.registered_entities[name] local height = max(0, math.ceil(ent.collisionbox[5] - ent.collisionbox[2]) - 1) |