init.lua 7.6 KB

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