redsky_asteroids.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. if otherworlds.settings.redsky_asteroids.enable then
  2. -- Approximate realm limits
  3. local YMIN = otherworlds.settings.redsky_asteroids.YMIN or 6000
  4. local YMAX = otherworlds.settings.redsky_asteroids.YMAX or 7000
  5. -- Register on_generated function for this layer
  6. minetest.register_on_generated(otherworlds.asteroids.create_on_generated(YMIN, YMAX, {
  7. c_air = minetest.get_content_id("air"),
  8. c_obsidian = minetest.get_content_id("default:obsidian"),
  9. c_stone = minetest.get_content_id("asteroid:redstone"),
  10. c_cobble = minetest.get_content_id("air"),
  11. c_gravel = minetest.get_content_id("asteroid:redgravel"),
  12. c_dust = minetest.get_content_id("asteroid:reddust"),
  13. c_ironore = minetest.get_content_id("asteroid:ironore"),
  14. c_copperore = minetest.get_content_id("asteroid:copperore"),
  15. c_goldore = minetest.get_content_id("asteroid:goldore"),
  16. c_diamondore = minetest.get_content_id("asteroid:diamondore"),
  17. c_meseore = minetest.get_content_id("asteroid:meseore"),
  18. c_waterice = minetest.get_content_id("default:ice"),
  19. c_atmos = minetest.get_content_id("asteroid:atmos"),
  20. c_snowblock = minetest.get_content_id("default:snowblock"),
  21. c_thennium = minetest.get_content_id('asteroid:redstone_thennium_ore'),
  22. }))
  23. -- Deco code for grass and crystal
  24. local TOPDECO = 200 -- how often surface decoration appears on top of asteroid cobble
  25. local crystal = {
  26. "crystals:ghost_crystal_1", "crystals:ghost_crystal_2",
  27. "crystals:red_crystal_1", "crystals:red_crystal_2",
  28. "crystals:rose_quartz_1", "crystals:rose_quartz_2",
  29. }
  30. -- Add surface decoration
  31. minetest.register_on_generated(function(minp, maxp)
  32. if minp.y < YMIN or maxp.y > YMAX then
  33. return
  34. end
  35. local bpos, ran
  36. local coal = minetest.find_nodes_in_area_under_air(minp, maxp,
  37. {"asteroid:redgravel"})
  38. for n = 1, #coal do
  39. bpos = {x = coal[n].x, y = coal[n].y + 1, z = coal[n].z }
  40. ran = math.random(TOPDECO)
  41. if ran == TOPDECO then -- crystals
  42. minetest.swap_node(bpos, {name = crystal[ math.random(1, #crystal) ] })
  43. end
  44. end
  45. end)
  46. end