From e09c39165008b663792f406735b46bf7ea439ae1 Mon Sep 17 00:00:00 2001 From: HeroOfTheWinds Date: Wed, 21 May 2014 13:25:12 -1000 Subject: [PATCH] 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. --- mods/mapgen/init.lua | 17 +++++++++++++---- mods/moontest/init.lua | 32 ++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/mods/mapgen/init.lua b/mods/mapgen/init.lua index 5b5582c2..3178250b 100644 --- a/mods/mapgen/init.lua +++ b/mods/mapgen/init.lua @@ -139,10 +139,19 @@ minetest.register_abm({ for x = -1,1 do for y = -1,0 do for z = -1,1 do - n_pos = {x=x + pos.x,y=y+pos.y,z=z+pos.z} - n_name = minetest.get_node(n_pos).name - if n_name == "moontest:vacuum" or n_name == "moontest:air" then - minetest.remove_node(n_pos) + --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_name = minetest.get_node(n_pos).name + if n_name == "moontest:vacuum" or n_name == "moontest:air" then + minetest.remove_node(n_pos) + end + end + end + end end end end diff --git a/mods/moontest/init.lua b/mods/moontest/init.lua index 187c9060..48e3f1af 100644 --- a/mods/moontest/init.lua +++ b/mods/moontest/init.lua @@ -119,13 +119,13 @@ minetest.register_on_dignode(function(pos, oldnode, digger) end end) --- Air dies ---this is the hackiest code I've ever written +-- Air gets filled with vacuum or moontest:air, depending on surroudings +-- this is the hackiest code I've ever written -- If neighbors worked as I would like it to, this wouldn't be necessary... minetest.register_abm({ - nodenames = {"moontest:air"}, - neighbors = {"moontest:vacuum"}, - interval = 1, + nodenames = {"moontest:air", "air"}, + neighbors = {"moontest:vacuum", "moontest:air"}, + interval = 2, --must be asynchronous with liquid ABM to avoid deadlock chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local x = pos.x @@ -157,7 +157,27 @@ minetest.register_abm({ if minetest.get_node(back).name == "moontest:vacuum" then minetest.set_node(pos, {name="moontest:vacuum"}) 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 })