init.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. --[[
  2. =====================================================================
  3. ** More Ores **
  4. By Calinou, with the help of Nore.
  5. Copyright (c) 2011-2015 Calinou and contributors.
  6. Licensed under the zlib license. See LICENSE.md for more information.
  7. =====================================================================
  8. --]]
  9. local S
  10. if minetest.get_modpath("intllib") then
  11. S = intllib.Getter()
  12. else
  13. S = function(s) return s end
  14. end
  15. local modpath = minetest.get_modpath("moreores")
  16. dofile(modpath .. "/_config.txt")
  17. dofile(modpath .. "/tools.lua")
  18. -- Utility functions
  19. -- =================
  20. local default_stone_sounds = default.node_sound_stone_defaults()
  21. local default_metal_sounds = default.node_sound_metal_defaults()
  22. local function get_recipe(c, name)
  23. if name == "sword" then
  24. return {{c}, {c}, {"group:stick"}}
  25. end
  26. if name == "shovel" then
  27. return {{c}, {"group:stick"}, {"group:stick"}}
  28. end
  29. if name == "axe" then
  30. return {{c, c}, {c, "group:stick"}, {"", "group:stick"}}
  31. end
  32. if name == "pick" then
  33. return {{c, c, c}, {"", "group:stick", ""}, {"", "group:stick", ""}}
  34. end
  35. if name == "hoe" then
  36. return {{c, c}, {"", "group:stick"}, {"", "group:stick"}}
  37. end
  38. if name == "block" then
  39. return {{c, c, c}, {c, c, c}, {c, c, c}}
  40. end
  41. if name == "lockedchest" then
  42. return {{"group:wood", "group:wood", "group:wood"}, {"group:wood", c, "group:wood"}, {"group:wood", "group:wood", "group:wood"}}
  43. end
  44. end
  45. local function add_ore(modname, description, mineral_name, oredef)
  46. local img_base = modname .. "_" .. mineral_name
  47. local toolimg_base = modname .. "_tool_"..mineral_name
  48. local tool_base = modname .. ":"
  49. local tool_post = "_" .. mineral_name
  50. local item_base = tool_base .. mineral_name
  51. local ingot = item_base .. "_ingot"
  52. local lump_item = item_base .. "_lump"
  53. local ingotcraft = ingot
  54. if oredef.makes.ore then
  55. minetest.register_node(modname .. ":mineral_" .. mineral_name, {
  56. description = S("%s Ore"):format(S(description)),
  57. tiles = {"default_stone.png^" .. modname .. "_mineral_" .. mineral_name .. ".png"},
  58. groups = utility.dig_groups("hardmineral", {ore = 1}),
  59. sounds = default_stone_sounds,
  60. drop = lump_item,
  61. silverpick_drop = true,
  62. })
  63. end
  64. if oredef.makes.block then
  65. local block_item = item_base .. "_block"
  66. minetest.register_node(block_item, {
  67. description = S("%s Block"):format(S(description)),
  68. tiles = { img_base .. "_block.png" },
  69. groups = utility.dig_groups("block", {conductor = 1, block = 1}),
  70. sounds = default_metal_sounds,
  71. })
  72. minetest.register_alias(mineral_name.."_block", block_item)
  73. if oredef.makes.ingot then
  74. minetest.register_craft( {
  75. output = block_item,
  76. recipe = get_recipe(ingot, "block")
  77. })
  78. minetest.register_craft( {
  79. output = ingot .. " 9",
  80. recipe = {
  81. { block_item }
  82. }
  83. })
  84. end
  85. end
  86. if oredef.makes.lump then
  87. minetest.register_craftitem(lump_item, {
  88. description = S("%s Lump"):format(S(description)),
  89. inventory_image = img_base .. "_lump.png",
  90. })
  91. minetest.register_alias(mineral_name .. "_lump", lump_item)
  92. if oredef.makes.ingot then
  93. minetest.register_craft({
  94. type = "cooking",
  95. output = ingot,
  96. recipe = lump_item
  97. })
  98. end
  99. end
  100. if oredef.makes.ingot then
  101. minetest.register_craftitem(ingot, {
  102. description = S("%s Ingot"):format(S(description)),
  103. inventory_image = img_base .. "_ingot.png",
  104. groups = {ingot = 1},
  105. })
  106. minetest.register_alias(mineral_name .. "_ingot", ingot)
  107. end
  108. oredef.oredef.ore_type = "scatter"
  109. oredef.oredef.ore = modname .. ":mineral_" .. mineral_name
  110. oredef.oredef.wherein = "default:stone"
  111. oregen.register_ore(oredef.oredef)
  112. end
  113. -- Add everything:
  114. local modname = "moreores"
  115. local oredefs = {
  116. silver = {
  117. description = "Silver",
  118. makes = {ore = true, block = true, lump = true, ingot = true, chest = false},
  119. oredef = {clust_scarcity = moreores_silver_chunk_size * moreores_silver_chunk_size * moreores_silver_chunk_size,
  120. clust_num_ores = moreores_silver_ore_per_chunk,
  121. clust_size = moreores_silver_chunk_radius,
  122. y_min = moreores_silver_min_depth,
  123. y_max = moreores_silver_max_depth
  124. },
  125. tools = {
  126. pick = {
  127. cracky = {times = {[1] = 2.60, [2] = 1.00, [3] = 0.60}, uses = 100, maxlevel= 1}
  128. },
  129. hoe = {
  130. uses = 300
  131. },
  132. shovel = {
  133. crumbly = {times = {[1] = 1.10, [2] = 0.40, [3] = 0.25}, uses = 100, maxlevel= 1}
  134. },
  135. axe = {
  136. choppy = {times = {[1] = 2.50, [2] = 0.80, [3] = 0.50}, uses = 100, maxlevel= 1},
  137. fleshy = {times = {[2] = 1.10, [3] = 0.60}, uses = 100, maxlevel= 1}
  138. },
  139. sword = {
  140. fleshy = {times = {[2] = 0.70, [3] = 0.30}, uses = 100, maxlevel= 1},
  141. snappy = {times = {[2] = 0.70, [3] = 0.30}, uses = 100, maxlevel= 1},
  142. choppy = {times = {[3] = 0.80}, uses = 100, maxlevel= 0}
  143. },
  144. },
  145. full_punch_interval = 1.0,
  146. damage_groups = {fleshy = 6},
  147. },
  148. tin = {
  149. description = "Tin",
  150. makes = {ore = true, block = true, lump = true, ingot = true, chest = false},
  151. oredef = {clust_scarcity = moreores_tin_chunk_size * moreores_tin_chunk_size * moreores_tin_chunk_size,
  152. clust_num_ores = moreores_tin_ore_per_chunk,
  153. clust_size = moreores_tin_chunk_radius,
  154. y_min = moreores_tin_min_depth,
  155. y_max = moreores_tin_max_depth
  156. },
  157. tools = {},
  158. },
  159. mithril = {
  160. description = "Mithril",
  161. makes = {ore = true, block = true, lump = true, ingot = true, chest = false},
  162. oredef = {clust_scarcity = moreores_mithril_chunk_size * moreores_mithril_chunk_size * moreores_mithril_chunk_size,
  163. clust_num_ores = moreores_mithril_ore_per_chunk,
  164. clust_size = moreores_mithril_chunk_radius,
  165. y_min = moreores_mithril_min_depth,
  166. y_max = moreores_mithril_max_depth
  167. },
  168. tools = {
  169. pick = {
  170. cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60}, uses = 200, maxlevel= 3}
  171. },
  172. hoe = {
  173. uses = 1000
  174. },
  175. shovel = {
  176. crumbly = {times = {[1] = 0.70, [2] = 0.35, [3] = 0.20}, uses = 200, maxlevel= 1}
  177. },
  178. axe = {
  179. choppy = {times = {[1] = 1.75, [2] = 0.45, [3] = 0.45}, uses = 200, maxlevel= 1},
  180. fleshy = {times = {[2] = 0.95, [3] = 0.30}, uses = 200, maxlevel= 1}
  181. },
  182. sword = {
  183. fleshy = {times = {[2] = 0.65, [3] = 0.25}, uses = 200, maxlevel= 1},
  184. snappy = {times = {[2] = 0.70, [3] = 0.25}, uses = 200, maxlevel= 1},
  185. choppy = {times = {[3] = 0.65}, uses = 200, maxlevel= 0}
  186. }
  187. },
  188. full_punch_interval = 0.45,
  189. damage_groups = {fleshy = 9},
  190. }
  191. }
  192. for orename,def in pairs(oredefs) do
  193. add_ore(modname, def.description, orename, def)
  194. end
  195. carts:register_rail(":carts:copperrail", {
  196. description = "Copper Rail",
  197. tiles = {
  198. "moreores_copper_rail.png", "moreores_copper_rail_curved.png",
  199. "moreores_copper_rail_t_junction.png", "moreores_copper_rail_crossing.png"
  200. },
  201. groups = carts:get_rail_groups(),
  202. }, {})
  203. minetest.register_craft({
  204. output = "carts:copperrail 16",
  205. recipe = {
  206. {"default:copper_ingot", "", "default:copper_ingot"},
  207. {"default:copper_ingot", "group:stick", "default:copper_ingot"},
  208. {"default:copper_ingot", "", "default:copper_ingot"},
  209. }
  210. })
  211. -- Added stairs registrations. By MustTest
  212. stairs.register_stair_and_slab(
  213. "silver",
  214. "moreores:silver_block",
  215. {cracky = 1, level = 2},
  216. {"moreores_silver_block.png"},
  217. "Silver Block",
  218. default.node_sound_metal_defaults()
  219. )
  220. stairs.register_stair_and_slab(
  221. "tin",
  222. "moreores:tin_block",
  223. {cracky = 1, level = 2},
  224. {"moreores_tin_block.png"},
  225. "Tin Block",
  226. default.node_sound_metal_defaults()
  227. )
  228. stairs.register_stair_and_slab(
  229. "mithril",
  230. "moreores:mithril_block",
  231. {cracky = 1, level = 2},
  232. {"moreores_mithril_block.png"},
  233. "Mithril Block",
  234. default.node_sound_metal_defaults()
  235. )