From feac802b792c2bcca3f4ece92afe0249e1ab3170 Mon Sep 17 00:00:00 2001 From: Red_King_Cyclops Date: Mon, 7 Oct 2019 21:15:45 +0000 Subject: [PATCH] added files --- vacuum.lua | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 vacuum.lua diff --git a/vacuum.lua b/vacuum.lua new file mode 100644 index 0000000..dc7ddd9 --- /dev/null +++ b/vacuum.lua @@ -0,0 +1,70 @@ +--vacuum code + +local old_is_pos_in_space = vacuum.is_pos_in_space +vacuum.is_pos_in_space = function(pos) + + --if pos.y < 23500 or pos.y > 24500 then + if (not (pos.y > 23500 and pos.y < 24500)) and (not (pos.y > 25000 and pos.y < 26000)) and (not (pos.y > 26500 and pos.y < 27500)) and (not (pos.y > 28000 and pos.y < 29000)) then + -- not in the atmosphere of a habitable planet + return old_is_pos_in_space(pos) + end + + -- atmosphere on habitable worlds + return false +end + +--[[ +local old_is_pos_on_earth = vacuum.is_pos_on_earth +vacuum.is_pos_on_earth = function(pos) + + if pos.y > 23500 or pos.y < 24500 then + -- in the atmosphere of a habitable planet + return true + end + + -- not in the atmosphere of habitable worlds + return old_is_pos_on_earth(pos) +end +]] + + +local c_vacuum = minetest.get_content_id("vacuum:vacuum") +local c_air = minetest.get_content_id("air") + +minetest.register_on_generated(function(minp, maxp, seed) + + --if minp.y < 23500 or maxp.y > 24500 then + if (not (minp.y > 23500 and maxp.y < 24500)) and (not (minp.y > 25000 and maxp.y < 26000)) and (not (minp.y > 26500 and maxp.y < 27500)) and (not (minp.y > 28000 and maxp.y < 29000)) then + return + end + + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local data = vm:get_data() + local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) + + for i in area:iter( + minp.x, minp.y, minp.z, + maxp.x, maxp.y, maxp.z + ) do + if data[i] == c_vacuum or data[i] == c_air then + data[i] = c_air + end + end + + vm:set_data(data) + vm:write_to_map() +end) + +--[[ +--Kind of works but is laggy +minetest.register_lbm({ + name = "space_travel:atmosphere_lbm", + run_at_every_load = true, + nodenames = {"vacuum:vacuum"}, + action = function(pos, node) + if pos.y >= 23500 and pos.y < 24500 then + minetest.set_node(pos, {name = "air"}) + end + end, +}) +]]