Use settings to determine spawn chance, frequency, level, & light requirements

This commit is contained in:
Jordan Irwin
2021-05-08 12:23:00 -07:00
parent 7ca26b4105
commit 7edfb6cb9b
5 changed files with 122 additions and 18 deletions

View File

@@ -12,32 +12,32 @@ end
core.register_abm({
nodenames = spawn_nodes,
neighbors = {"air"},
interval = 30,
chance = 9000,
interval = sneeker.spawn_interval,
chance = sneeker.spawn_chance,
action = function(pos, node, _, active_object_count_wider)
if active_object_count_wider > 5 then
return
end
pos.y = pos.y+1
if not core.get_node_light(pos) then
if pos.y > sneeker.spawn_maxheight then
return
end
if core.get_node_light(pos) > 5 then
if pos.y < sneeker.spawn_minheight then
return
end
if core.get_node_light(pos) < -1 then
return
end
if pos.y > 31000 then
return
end
if core.get_node(pos).name ~= "air" then
return
end
pos.y = pos.y+1
if core.get_node(pos).name ~= "air" then
-- needs two vertical air nodes to spawn
for _, node_pos in ipairs({pos, {x=pos.x, y=pos.y+1, z=pos.z}}) do
if core.get_node(node_pos).name ~= "air" then
return
end
end
local llevel = core.get_node_light(pos)
if not llevel or llevel > sneeker.spawn_maxlight or llevel < sneeker.spawn_minlight then
return
end
core.add_entity(pos, "sneeker:sneeker")
end
})