init.lua 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. local diggroup = "hardmineral"
  56. if mineral_name == "tin" then
  57. diggroup = "mineral"
  58. elseif mineral_name == "mithril" then
  59. diggroup = "obsidian"
  60. end
  61. minetest.register_node(modname .. ":mineral_" .. mineral_name, {
  62. description = S("%s Ore"):format(S(description)),
  63. tiles = {"default_stone.png^" .. modname .. "_mineral_" .. mineral_name .. ".png"},
  64. groups = utility.dig_groups(diggroup, {ore = 1}),
  65. sounds = default_stone_sounds,
  66. drop = lump_item,
  67. _tnt_drop = lump_item .. " 2",
  68. silverpick_drop = true,
  69. place_param2 = 10,
  70. })
  71. minetest.register_alias(
  72. modname .. ":mineral_" .. mineral_name .. "_mined",
  73. modname .. ":mineral_" .. mineral_name)
  74. end
  75. if oredef.makes.block then
  76. local block_item = item_base .. "_block"
  77. minetest.register_node(block_item, {
  78. description = S("%s Block"):format(S(description)),
  79. tiles = { img_base .. "_block.png" },
  80. groups = utility.dig_groups("block", {conductor = 1, block = 1}),
  81. sounds = default_metal_sounds,
  82. })
  83. minetest.register_alias(mineral_name.."_block", block_item)
  84. if oredef.makes.ingot then
  85. minetest.register_craft( {
  86. output = block_item,
  87. recipe = get_recipe(ingot, "block")
  88. })
  89. minetest.register_craft( {
  90. output = ingot .. " 9",
  91. recipe = {
  92. { block_item }
  93. }
  94. })
  95. end
  96. end
  97. if oredef.makes.lump then
  98. minetest.register_craftitem(lump_item, {
  99. description = S("%s Lump"):format(S(description)),
  100. inventory_image = img_base .. "_lump.png",
  101. })
  102. minetest.register_alias(mineral_name .. "_lump", lump_item)
  103. if oredef.makes.ingot then
  104. minetest.register_craft({
  105. type = "cooking",
  106. output = ingot,
  107. recipe = lump_item
  108. })
  109. end
  110. end
  111. if oredef.makes.ingot then
  112. minetest.register_craftitem(ingot, {
  113. description = S("%s Ingot"):format(S(description)),
  114. inventory_image = img_base .. "_ingot.png",
  115. groups = {ingot = 1},
  116. })
  117. minetest.register_alias(mineral_name .. "_ingot", ingot)
  118. end
  119. oredef.oredef.ore_type = "scatter"
  120. oredef.oredef.ore = modname .. ":mineral_" .. mineral_name
  121. oredef.oredef.wherein = "default:stone"
  122. oregen.register_ore(oredef.oredef)
  123. end
  124. -- Add everything:
  125. local modname = "moreores"
  126. local oredefs = {
  127. silver = {
  128. description = "Silver",
  129. makes = {ore = true, block = true, lump = true, ingot = true, chest = false},
  130. oredef = {clust_scarcity = moreores_silver_chunk_size * moreores_silver_chunk_size * moreores_silver_chunk_size,
  131. clust_num_ores = moreores_silver_ore_per_chunk,
  132. clust_size = moreores_silver_chunk_radius,
  133. y_min = moreores_silver_min_depth,
  134. y_max = moreores_silver_max_depth
  135. },
  136. tools = {
  137. pick = {
  138. cracky = {times = {[1] = 2.60, [2] = 1.00, [3] = 0.60}, uses = 100, maxlevel= 1}
  139. },
  140. hoe = {
  141. uses = 300
  142. },
  143. shovel = {
  144. crumbly = {times = {[1] = 1.10, [2] = 0.40, [3] = 0.25}, uses = 100, maxlevel= 1}
  145. },
  146. axe = {
  147. choppy = {times = {[1] = 2.50, [2] = 0.80, [3] = 0.50}, uses = 100, maxlevel= 1},
  148. fleshy = {times = {[2] = 1.10, [3] = 0.60}, uses = 100, maxlevel= 1}
  149. },
  150. sword = {
  151. fleshy = {times = {[2] = 0.70, [3] = 0.30}, uses = 100, maxlevel= 1},
  152. snappy = {times = {[2] = 0.70, [3] = 0.30}, uses = 100, maxlevel= 1},
  153. choppy = {times = {[3] = 0.80}, uses = 100, maxlevel= 0}
  154. },
  155. },
  156. full_punch_interval = 1.0,
  157. damage_groups = {fleshy = 6*500},
  158. },
  159. tin = {
  160. description = "Tin",
  161. makes = {ore = true, block = true, lump = true, ingot = true, chest = false},
  162. oredef = {clust_scarcity = moreores_tin_chunk_size * moreores_tin_chunk_size * moreores_tin_chunk_size,
  163. clust_num_ores = moreores_tin_ore_per_chunk,
  164. clust_size = moreores_tin_chunk_radius,
  165. y_min = moreores_tin_min_depth,
  166. y_max = moreores_tin_max_depth
  167. },
  168. tools = {},
  169. },
  170. mithril = {
  171. description = "Mithril",
  172. makes = {ore = true, block = true, lump = true, ingot = true, chest = false},
  173. oredef = {clust_scarcity = moreores_mithril_chunk_size * moreores_mithril_chunk_size * moreores_mithril_chunk_size,
  174. clust_num_ores = moreores_mithril_ore_per_chunk,
  175. clust_size = moreores_mithril_chunk_radius,
  176. y_min = moreores_mithril_min_depth,
  177. y_max = moreores_mithril_max_depth
  178. },
  179. tools = {
  180. pick = {
  181. cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60}, uses = 200, maxlevel= 3}
  182. },
  183. hoe = {
  184. uses = 1000
  185. },
  186. shovel = {
  187. crumbly = {times = {[1] = 0.70, [2] = 0.35, [3] = 0.20}, uses = 200, maxlevel= 1}
  188. },
  189. axe = {
  190. choppy = {times = {[1] = 1.75, [2] = 0.45, [3] = 0.45}, uses = 200, maxlevel= 1},
  191. fleshy = {times = {[2] = 0.95, [3] = 0.30}, uses = 200, maxlevel= 1}
  192. },
  193. sword = {
  194. fleshy = {times = {[2] = 0.65, [3] = 0.25}, uses = 200, maxlevel= 1},
  195. snappy = {times = {[2] = 0.70, [3] = 0.25}, uses = 200, maxlevel= 1},
  196. choppy = {times = {[3] = 0.65}, uses = 200, maxlevel= 0}
  197. }
  198. },
  199. full_punch_interval = 0.45,
  200. damage_groups = {fleshy = 9*500},
  201. }
  202. }
  203. for orename,def in pairs(oredefs) do
  204. add_ore(modname, def.description, orename, def)
  205. end
  206. carts:register_rail(":carts:copperrail", {
  207. description = "Copper Rail",
  208. tiles = {
  209. "moreores_copper_rail.png", "moreores_copper_rail_curved.png",
  210. "moreores_copper_rail_t_junction.png", "moreores_copper_rail_crossing.png"
  211. },
  212. groups = carts:get_rail_groups(),
  213. }, {})
  214. minetest.register_craft({
  215. output = "carts:copperrail 16",
  216. recipe = {
  217. {"default:copper_ingot", "", "default:copper_ingot"},
  218. {"default:copper_ingot", "group:stick", "default:copper_ingot"},
  219. {"default:copper_ingot", "", "default:copper_ingot"},
  220. }
  221. })
  222. -- Added stairs registrations. By MustTest
  223. stairs.register_stair_and_slab(
  224. "silver",
  225. "moreores:silver_block",
  226. {cracky = 1, level = 2},
  227. {"moreores_silver_block.png"},
  228. "Silver Block",
  229. default.node_sound_metal_defaults()
  230. )
  231. stairs.register_stair_and_slab(
  232. "tin",
  233. "moreores:tin_block",
  234. {cracky = 1, level = 2},
  235. {"moreores_tin_block.png"},
  236. "Tin Block",
  237. default.node_sound_metal_defaults()
  238. )
  239. stairs.register_stair_and_slab(
  240. "mithril",
  241. "moreores:mithril_block",
  242. {cracky = 1, level = 2},
  243. {"moreores_mithril_block.png"},
  244. "Mithril Block",
  245. default.node_sound_metal_defaults()
  246. )