Put node light in local variable & add debugging output
This commit is contained in:
parent
a5025cdfb8
commit
a73dc9aa39
21
spawn.lua
21
spawn.lua
@ -22,19 +22,30 @@ minetest.register_abm({
|
|||||||
if active_object_count_wider > 5 then
|
if active_object_count_wider > 5 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check light value of node
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if not minetest.get_node_light(pos) then
|
local node_light = minetest.get_node_light(pos)
|
||||||
|
|
||||||
|
-- Debugging spawning
|
||||||
|
sneaker.log_debug('Node light level at ' .. tostring(pos.x) .. ',' .. tostring(pos.y) .. ': ' .. tostring(node_light))
|
||||||
|
|
||||||
|
if not node_light then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node_light(pos) > sneeker.spawn_maxlight then
|
if node_light > sneeker.spawn_maxlight then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node_light(pos) < -1 then
|
if node_light < -1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Spawn range
|
||||||
if pos.y > 31000 then
|
if pos.y > 31000 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Node must be touching air
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
if minetest.get_node(pos).name ~= "air" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -42,7 +53,7 @@ minetest.register_abm({
|
|||||||
if minetest.get_node(pos).name ~= "air" then
|
if minetest.get_node(pos).name ~= "air" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get total count of sneekers in world
|
-- Get total count of sneekers in world
|
||||||
local name, count
|
local name, count
|
||||||
for name in pairs(minetest.luaentities) do
|
for name in pairs(minetest.luaentities) do
|
||||||
@ -51,7 +62,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if count >= sneeker.spawn_cap then return end -- Max sneekers already exist
|
if count >= sneeker.spawn_cap then return end -- Max sneekers already exist
|
||||||
|
|
||||||
sneeker.spawn(pos)
|
sneeker.spawn(pos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user