init.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. underworld = {
  2. depth = tonumber(minetest.settings:get("underworld_depth")) or -25000,
  3. barrier_size = tonumber(minetest.settings:get("underworld_barrier_size")) or 20,
  4. }
  5. local modpath = minetest.get_modpath("underworld")
  6. dofile(modpath .. "/nodes.lua")
  7. dofile(modpath .. "/portals.lua")
  8. dofile(modpath .. "/mapgen.lua")
  9. -- Miscellaneous
  10. -- Vaporize water in the underworld
  11. minetest.register_abm({
  12. label = "Vaporize water in underworld",
  13. nodenames = {"default:water_source", "default:water_flowing", "default:river_water_source", "default:river_water_flowing"},
  14. interval = 1,
  15. chance = 1,
  16. action = function(pos, node)
  17. if pos.y <= underworld.depth then
  18. minetest.remove_node(pos)
  19. minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25})
  20. end
  21. end,
  22. })
  23. -- Spawn extra-aggressive dungeon masters in dungeons
  24. if minetest.get_modpath("mobs_monster") then
  25. mobs:spawn({
  26. name = "mobs_monster:dungeon_master",
  27. nodes = {"underworld:brick"},
  28. min_light = 0,
  29. max_light = minetest.LIGHT_MAX - 2,
  30. interval = 10,
  31. chance = 4,
  32. active_object_count = 1,
  33. max_height = underworld.depth,
  34. on_spawn = function(self, pos)
  35. self.shoot_interval = 0.5
  36. self.dogshoot_switch = 0
  37. end
  38. })
  39. end
  40. -- Disallow connecting mese portals across the underworld boundary
  41. if minetest.get_modpath("meseportals") then
  42. local old_can_connect = meseportals.can_connect
  43. meseportals.can_connect = function(src_portal, dest_portal)
  44. local src_y = src_portal.pos.y
  45. local dest_y = dest_portal.pos.y
  46. if math.min(src_y, dest_y) <= underworld.depth and underworld.depth < math.max(src_y, dest_y) then
  47. return false, "Mese portals can't connect into or out of the underworld."
  48. end
  49. return old_can_connect(src_portal, dest_portal)
  50. end
  51. end