The air/vacuum fix to end all fixes

Probably will have a bug in the next few days. :P
Fixed air and vacuum not flowing back in when liquids are removed.  Also
added an ABM to regular air to make it change to moontest air or vacuum
based on neighbors.  Liquid no longer deletes atmosphere diagonally
placed from it.
This commit is contained in:
HeroOfTheWinds 2014-05-21 13:25:12 -10:00
parent 170596c13f
commit e09c391650
2 changed files with 39 additions and 10 deletions

View file

@ -139,6 +139,11 @@ minetest.register_abm({
for x = -1,1 do for x = -1,1 do
for y = -1,0 do for y = -1,0 do
for z = -1,1 do for z = -1,1 do
--ignore diagonals
if x ~= 1 and z ~= 1 then
if x ~= -1 and z ~= 1 then
if x ~= 1 and z ~= -1 then
if x ~= -1 and z ~= -1 then
n_pos = {x=x + pos.x,y=y+pos.y,z=z+pos.z} n_pos = {x=x + pos.x,y=y+pos.y,z=z+pos.z}
n_name = minetest.get_node(n_pos).name n_name = minetest.get_node(n_pos).name
if n_name == "moontest:vacuum" or n_name == "moontest:air" then if n_name == "moontest:vacuum" or n_name == "moontest:air" then
@ -147,5 +152,9 @@ minetest.register_abm({
end end
end end
end end
end
end
end
end
end, end,
}) })

View file

@ -119,13 +119,13 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
end end
end) end)
-- Air dies -- Air gets filled with vacuum or moontest:air, depending on surroudings
--this is the hackiest code I've ever written -- this is the hackiest code I've ever written
-- If neighbors worked as I would like it to, this wouldn't be necessary... -- If neighbors worked as I would like it to, this wouldn't be necessary...
minetest.register_abm({ minetest.register_abm({
nodenames = {"moontest:air"}, nodenames = {"moontest:air", "air"},
neighbors = {"moontest:vacuum"}, neighbors = {"moontest:vacuum", "moontest:air"},
interval = 1, interval = 2, --must be asynchronous with liquid ABM to avoid deadlock
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local x = pos.x local x = pos.x
@ -157,7 +157,27 @@ minetest.register_abm({
if minetest.get_node(back).name == "moontest:vacuum" then if minetest.get_node(back).name == "moontest:vacuum" then
minetest.set_node(pos, {name="moontest:vacuum"}) minetest.set_node(pos, {name="moontest:vacuum"})
end end
--now cross reference if air should get filled with moontest:air
if node.name == "air" then
if minetest.get_node(left).name == "moontest:air" then
minetest.set_node(pos, {name="moontest:air"})
end
if minetest.get_node(right).name == "moontest:air" then
minetest.set_node(pos, {name="moontest:air"})
end
if minetest.get_node(up).name == "moontest:air" then
minetest.set_node(pos, {name="moontest:air"})
end
if minetest.get_node(down).name == "moontest:air" then
minetest.set_node(pos, {name="moontest:air"})
end
if minetest.get_node(forward).name == "moontest:air" then
minetest.set_node(pos, {name="moontest:air"})
end
if minetest.get_node(back).name == "moontest:air" then
minetest.set_node(pos, {name="moontest:air"})
end
end
end end
}) })