Trying something else.
[edit]
Victory. Turns out we needed to eliminate air nodes surrounded by atmosphere before doing air spread. That way unwanted loner air nodes don't expand exponentially.
- Code: Select all
if AIRGEN then
minetest.register_craft({
output = "mrealms:airgen",
recipe = {
{"default:steel_ingot", "mrealms:waterice", "default:steel_ingot"},
{"mrealms:waterice", "mrealms:dilithium", "mrealms:waterice"},
{"default:steel_ingot", "mrealms:waterice", "default:steel_ingot"},
},
})
minetest.register_node("mrealms:airgen", {
description = "Air Generator",
tiles = {"mrealms_airgen.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
paramtype = "light",
on_construct = function(pos)
local env = minetest.env
local x = pos.x
local y = pos.y
local z = pos.z
for i = -1,1 do
for j = -1,1 do
for k = -1,1 do
if not (i == 0 and j == 0 and k == 0) then
local nodename = env:get_node({x=x+i,y=y+j,z=z+k}).name
if minetest.get_item_group(nodename,'atmosphere') == 1 then --or nodename == "air" then
env:add_node({x=x+i,y=y+j,z=z+k},{name="air"})
--env:remove_node({x=x+i,y=y+j,z=z+k})
print ("[moonrealm] Added air node")
end
end
end
end
end
end
})
-- Air spread abm, life support air and pine needles.
minetest.register_abm({
nodenames = {"air"},
neighbors = {"group:atmosphere"},--, "air"},
interval = AIRINT,
chance = 9,
action = function(pos, node, active_object_count, active_object_count_wider)
if pos.y < AIRFLOOR then return end -- below threshold
local env = minetest.env
if not env:find_node_near(pos, 1, {'air'}) then env:remove_node(pos) print ("[moonrealm] Air Dissipates") return end
local x = pos.x
local y = pos.y
local z = pos.z
for i = -1,1 do
for j = -1,1 do
for k = -1,1 do
if not (i == 0 and j == 0 and k == 0) then
local nodename = env:get_node({x=x+i,y=y+j,z=z+k}).name
if minetest.get_item_group(nodename,'atmosphere') == 1 then --or nodename == "air" then
env:add_node({x=x+i,y=y+j,z=z+k},{name="air"})
print ("[moonrealm] Air spreads ("..i.." "..j.." "..k..")")
end
end
end
end
end
end
})
end





