init.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. --------------------------------------------------------------------------------
  2. -- Gem Minerals Mod for Must Test Survival
  3. -- Author: GoldFireUn
  4. -- License of Source Code: MIT
  5. -- License of Media: CC BY-SA 3.0
  6. --------------------------------------------------------------------------------
  7. if not minetest.global_exists("gem_minerals") then gem_minerals = {} end
  8. gem_minerals.modpath = minetest.get_modpath("gem_minerals")
  9. local gems = {
  10. {name="ruby", desc="Ruby", hardness=20},
  11. {name="amethyst", desc="Amethyst", hardness=12},
  12. {name="sapphire", desc="Sapphire", hardness=18},
  13. {name="emerald", desc="Emerald", hardness=15},
  14. }
  15. if not gem_minerals.registered then
  16. for k, v in ipairs(gems) do
  17. local ore = "gems:" .. v.name .. "_ore"
  18. local block = "gems:" .. v.name .. "_block"
  19. local gem = "gems:" .. v.name .. "_gem"
  20. local raw = "gems:raw_" .. v.name
  21. -- Ore.
  22. minetest.register_node(":" .. ore, {
  23. description = v.desc .. " Ore",
  24. tiles = {"default_stone.png^gem_minerals_" .. v.name .. "_ore.png"},
  25. is_ground_content = true,
  26. groups = utility.dig_groups("hardstone"),
  27. sounds = default.node_sound_stone_defaults(),
  28. drop = "gems:raw_" .. v.name,
  29. silverpick_drop = true,
  30. place_param2 = 10,
  31. })
  32. minetest.register_alias(ore .. "_mined", ore)
  33. -- Block.
  34. minetest.register_node(":" .. block, {
  35. description = v.desc .. " Block",
  36. tiles = {"gem_minerals_" .. v.name .. "_block.png"},
  37. is_ground_content = false,
  38. groups = utility.dig_groups("obsidian"),
  39. sounds = default.node_sound_stone_defaults(),
  40. drop = gem .. " 8",
  41. silverpick_drop = block,
  42. })
  43. -- Cut Gem.
  44. minetest.register_craftitem(":" .. gem, {
  45. description = v.desc .. " Gem",
  46. inventory_image = "gem_minerals_" .. v.name .. "_gem.png",
  47. groups = {gem = 1, crystal = 1},
  48. })
  49. -- Raw gem.
  50. minetest.register_craftitem(":" .. raw, {
  51. description = "Uncut " .. v.desc .. " Gem",
  52. inventory_image = "gem_minerals_raw_" .. v.name .. ".png",
  53. groups = {gem = 1, crystal = 1},
  54. })
  55. -- Block craft.
  56. minetest.register_craft({
  57. output = block,
  58. recipe = {
  59. {gem, gem, gem},
  60. {gem, "default:stone", gem},
  61. {gem, gem, gem},
  62. }
  63. })
  64. -- Get gems back from block.
  65. minetest.register_craft({
  66. type = "shapeless",
  67. output = gem .. " 8",
  68. recipe = {block},
  69. })
  70. -- Cut raw gem.
  71. minetest.register_craft({
  72. type = "cutting",
  73. output = gem,
  74. recipe = raw,
  75. hardness = v.hardness,
  76. })
  77. end
  78. local c = "gem_minerals:core"
  79. local f = gem_minerals.modpath .. "/init.lua"
  80. reload.register_file(c, f, false)
  81. gem_minerals.registered = true
  82. end