Repository for the space_travel mod.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8KB

  1. --vacuum code
  2. local old_is_pos_in_space = vacuum.is_pos_in_space
  3. vacuum.is_pos_in_space = function(pos)
  4. --if pos.y < 23500 or pos.y > 24500 then
  5. 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
  6. -- not in the atmosphere of a habitable planet
  7. return old_is_pos_in_space(pos)
  8. end
  9. -- atmosphere on habitable worlds
  10. return false
  11. end
  12. --[[
  13. local old_is_pos_on_earth = vacuum.is_pos_on_earth
  14. vacuum.is_pos_on_earth = function(pos)
  15. if pos.y > 23500 or pos.y < 24500 then
  16. -- in the atmosphere of a habitable planet
  17. return true
  18. end
  19. -- not in the atmosphere of habitable worlds
  20. return old_is_pos_on_earth(pos)
  21. end
  22. ]]
  23. local c_vacuum = minetest.get_content_id("vacuum:vacuum")
  24. local c_air = minetest.get_content_id("air")
  25. minetest.register_on_generated(function(minp, maxp, seed)
  26. --if minp.y < 23500 or maxp.y > 24500 then
  27. 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
  28. return
  29. end
  30. local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
  31. local data = vm:get_data()
  32. local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
  33. for i in area:iter(
  34. minp.x, minp.y, minp.z,
  35. maxp.x, maxp.y, maxp.z
  36. ) do
  37. if data[i] == c_vacuum or data[i] == c_air then
  38. data[i] = c_air
  39. end
  40. end
  41. vm:set_data(data)
  42. vm:write_to_map()
  43. end)
  44. --[[
  45. --Kind of works but is laggy
  46. minetest.register_lbm({
  47. name = "space_travel:atmosphere_lbm",
  48. run_at_every_load = true,
  49. nodenames = {"vacuum:vacuum"},
  50. action = function(pos, node)
  51. if pos.y >= 23500 and pos.y < 24500 then
  52. minetest.set_node(pos, {name = "air"})
  53. end
  54. end,
  55. })
  56. ]]