summaryrefslogtreecommitdiff
path: root/spawner.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-05-21 19:35:24 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2016-05-21 19:35:24 +0100
commit1a53844f610ed59a2804eabbcdff4576da340858 (patch)
treeeb79f70b7964256c82755981a687002783fe6156 /spawner.lua
parent67aa752c4433c7172cb7ac86728c455d986678bf (diff)
Tweak spawner slightly
Diffstat (limited to 'spawner.lua')
-rw-r--r--spawner.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/spawner.lua b/spawner.lua
index d797184..4d30303 100644
--- a/spawner.lua
+++ b/spawner.lua
@@ -48,14 +48,14 @@ minetest.register_node("mobs:spawner", {
local xlig = tonumber(comm[3]) -- max light
local num = tonumber(comm[4]) -- total mobs in area
local pla = tonumber(comm[5]) -- player distance (0 to disable)
- local yof = tonumber(comm[6]) -- Y offset to spawn mob
+ local yof = tonumber(comm[6]) or 0 -- Y offset to spawn mob
if mob and mob ~= "" and mobs.spawning_mobs[mob] == true
and num and num >= 0 and num <= 10
and mlig and mlig >= 0 and mlig <= 15
and xlig and xlig >= 0 and xlig <= 15
and pla and pla >=0 and pla <= 20
- and yof > -10 and yof < 10 then
+ and yof and yof > -10 and yof < 10 then
meta:set_string("command", fields.text)
meta:set_string("infotext", "Spawner Active (" .. mob .. ")")
@@ -76,9 +76,6 @@ minetest.register_abm({
action = function(pos, node, active_object_count, active_object_count_wider)
- -- check objects inside 9x9 area around spawner
- local objs = minetest.get_objects_inside_radius(pos, 9)
-
-- get meta and command
local meta = minetest.get_meta(pos)
local comm = meta:get_string("command"):split(" ")
@@ -96,6 +93,8 @@ minetest.register_abm({
return
end
+ -- check objects inside 9x9 area around spawner
+ local objs = minetest.get_objects_inside_radius(pos, 9)
local count = 0
local ent = nil