init.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. gem_minerals = gem_minerals or {}
  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. })
  31. -- Block.
  32. minetest.register_node(":" .. block, {
  33. description = v.desc .. " Block",
  34. tiles = {"gem_minerals_" .. v.name .. "_block.png"},
  35. is_ground_content = false,
  36. groups = utility.dig_groups("obsidian"),
  37. sounds = default.node_sound_stone_defaults(),
  38. drop = gem .. " 8",
  39. silverpick_drop = block,
  40. })
  41. -- Cut Gem.
  42. minetest.register_craftitem(":" .. gem, {
  43. description = v.desc .. " Gem",
  44. inventory_image = "gem_minerals_" .. v.name .. "_gem.png",
  45. })
  46. -- Raw gem.
  47. minetest.register_craftitem(":" .. raw, {
  48. description = "Uncut " .. v.desc .. " Gem",
  49. inventory_image = "gem_minerals_raw_" .. v.name .. ".png",
  50. })
  51. -- Block craft.
  52. minetest.register_craft({
  53. output = block,
  54. recipe = {
  55. {gem, gem, gem},
  56. {gem, "default:stone", gem},
  57. {gem, gem, gem},
  58. }
  59. })
  60. -- Get gems back from block.
  61. minetest.register_craft({
  62. type = "shapeless",
  63. output = gem .. " 8",
  64. recipe = {block},
  65. })
  66. -- Cut raw gem.
  67. minetest.register_craft({
  68. type = "cutting",
  69. output = gem,
  70. recipe = raw,
  71. hardness = v.hardness,
  72. })
  73. end
  74. local c = "gem_minerals:core"
  75. local f = gem_minerals.modpath .. "/init.lua"
  76. reload.register_file(c, f, false)
  77. gem_minerals.registered = true
  78. end