init.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. instant_ores = {}
  2. instant_ores.register_gen_ore = function(node, rarity, ymax, ymax_deep)
  3. if rarity < 0 then rarity = 0 end
  4. local count_large = math.ceil(48/rarity) + 1
  5. local count_small = math.ceil(24/rarity) + 1
  6. local dense_rarity = math.ceil(rarity * 3/4)
  7. minetest.register_ore({
  8. ore_type = "scatter",
  9. ore = node,
  10. wherein = "default:stone",
  11. clust_scarcity = dense_rarity * dense_rarity * dense_rarity,
  12. clust_num_ores = count_large,
  13. clust_size = 3,
  14. y_min = 1025,
  15. y_max = 31000,
  16. })
  17. minetest.register_ore({
  18. ore_type = "scatter",
  19. ore = node,
  20. wherein = "default:stone",
  21. clust_scarcity = rarity * rarity * rarity,
  22. clust_num_ores = count_small,
  23. clust_size = 3,
  24. y_min = ymax_deep,
  25. y_max = ymax,
  26. })
  27. minetest.register_ore({
  28. ore_type = "scatter",
  29. ore = node,
  30. wherein = "default:stone",
  31. clust_scarcity = dense_rarity * dense_rarity * dense_rarity,
  32. clust_num_ores = count_large,
  33. clust_size = 3,
  34. y_min = -31000,
  35. y_max = ymax_deep,
  36. })
  37. end
  38. instant_ores.register_armorset = function(
  39. mod,
  40. name,
  41. desc,
  42. color,
  43. level,
  44. ingredient,
  45. optional_durability,
  46. infinite_use,
  47. shield_damage_sound,
  48. optional_protection,
  49. hurt_back,
  50. optional_weight)
  51. if not minetest.get_modpath("3d_armor") then return end
  52. local durability = optional_durability or (20*level*level*level)
  53. local uses = infinite_use and 0 or (65536 / durability)
  54. local weight = optional_weight or 1
  55. local default_protection = 24 - 20/((level >= 1) and level*level/2 or 1)
  56. local big_armor = optional_protection or default_protection
  57. local small_armor = (optional_protection or default_protection)*0.66
  58. local sound = shield_damage_sound or "default_dig_metal"
  59. --local sanity = nil
  60. armor:register_armor(":"..mod..":helmet_"..name, {
  61. description = desc.." Helmet",
  62. inventory_image = "armor_inv_helmet.png^[colorize:"..color,
  63. texture = "3d_armor_dummy_image.png^(armor_helmet.png^[colorize:"..color..")^3d_armor_dummy_image",
  64. -- I'm not going to try to explain how this texture hack works. Really, it shouldn't.
  65. preview = "3d_armor_preview_dummy_image.png^(armor_helmet_preview.png^[colorize:"..color..")^3d_armor_preview_dummy_image",
  66. groups = {armor_head=1, armor_heal=0, armor_use=uses,
  67. physics_speed=-0.01*weight, physics_gravity=0.01*weight},
  68. reciprocate_damage = hurt_back,
  69. armor_groups = {fleshy=small_armor},
  70. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=level},
  71. })
  72. armor:register_armor(":"..mod..":chestplate_"..name, {
  73. description = desc.." Chestplate",
  74. inventory_image = "armor_inv_chestplate.png^[colorize:"..color,
  75. texture = "3d_armor_dummy_image.png^(armor_chestplate.png^[colorize:"..color..")^3d_armor_dummy_image",
  76. preview = "3d_armor_preview_dummy_image.png^(armor_chestplate_preview.png^[colorize:"..color..")^3d_armor_preview_dummy_image",
  77. groups = {armor_torso=1, armor_heal=0, armor_use=uses,
  78. physics_speed=-0.04*weight, physics_gravity=0.04*weight},
  79. reciprocate_damage = hurt_back,
  80. armor_groups = {fleshy=big_armor},
  81. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=level},
  82. })
  83. armor:register_armor(":"..mod..":leggings_"..name, {
  84. description = desc.." Leggings",
  85. inventory_image = "armor_inv_leggings.png^[colorize:"..color,
  86. texture = "3d_armor_dummy_image.png^(armor_leggings.png^[colorize:"..color..")^3d_armor_dummy_image",
  87. preview = "3d_armor_preview_dummy_image.png^(armor_leggings_preview.png^[colorize:"..color..")^3d_armor_preview_dummy_image",
  88. groups = {armor_legs=1, armor_heal=0, armor_use=uses,
  89. physics_speed=-0.03*weight, physics_gravity=0.03*weight},
  90. reciprocate_damage = hurt_back,
  91. armor_groups = {fleshy=big_armor},
  92. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=level},
  93. })
  94. armor:register_armor(":"..mod..":boots_"..name, {
  95. description = desc.." Boots",
  96. inventory_image = "armor_inv_boots.png^[colorize:"..color,
  97. texture = "3d_armor_dummy_image.png^(armor_boots.png^[colorize:"..color..")^3d_armor_dummy_image",
  98. preview = "3d_armor_preview_dummy_image.png^(armor_boots_preview.png^[colorize:"..color..")^3d_armor_preview_dummy_image",
  99. groups = {armor_feet=1, armor_heal=0, armor_use=uses,
  100. physics_speed=-0.01*weight, physics_gravity=0.01*weight},
  101. reciprocate_damage = hurt_back,
  102. armor_groups = {fleshy=small_armor},
  103. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=level},
  104. })
  105. minetest.register_craft({
  106. output = mod..":helmet_"..name,
  107. recipe = {
  108. {ingredient, ingredient, ingredient},
  109. {ingredient, "", ingredient},
  110. {"", "", ""},
  111. },
  112. })
  113. minetest.register_craft({
  114. output = mod..":chestplate_"..name,
  115. recipe = {
  116. {ingredient, "", ingredient},
  117. {ingredient, ingredient, ingredient},
  118. {ingredient, ingredient, ingredient},
  119. },
  120. })
  121. minetest.register_craft({
  122. output = mod..":leggings_"..name,
  123. recipe = {
  124. {ingredient, ingredient, ingredient},
  125. {ingredient, "", ingredient},
  126. {ingredient, "", ingredient},
  127. },
  128. })
  129. minetest.register_craft({
  130. output = mod..":boots_"..name,
  131. recipe = {
  132. {ingredient, "", ingredient},
  133. {ingredient, "", ingredient},
  134. },
  135. })
  136. if not minetest.get_modpath("shields") then return end
  137. armor:register_armor(":"..mod..":shield_"..name, {
  138. description = desc.." Shield",
  139. inventory_image = "armor_inv_shield.png^[colorize:"..color,
  140. texture = "3d_armor_dummy_image.png^(armor_shield.png^[colorize:"..color..")^3d_armor_dummy_image.png",
  141. preview = "3d_armor_preview_dummy_image.png^(armor_shield_preview.png^[colorize:"..color..")^3d_armor_preview_dummy_image.png",
  142. groups = {armor_shield=1, armor_heal=0, armor_use=uses,
  143. physics_speed=-0.03*weight, physics_gravity=0.03*weight},
  144. armor_groups = {fleshy=small_armor},
  145. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=level},
  146. reciprocate_damage = hurt_back,
  147. on_damage = function(player)
  148. if not minetest.settings:get_bool("shields_disable_sounds") then
  149. minetest.sound_play(sound, {
  150. pos = player:get_pos(),
  151. max_hear_distance = 10,
  152. gain = 0.5,
  153. })
  154. end
  155. end,
  156. on_destroy = function(player)
  157. if not minetest.settings:get_bool("shields_disable_sounds") then
  158. minetest.sound_play("default_tool_breaks", {
  159. pos = player:get_pos(),
  160. max_hear_distance = 10,
  161. gain = 0.5,
  162. })
  163. end
  164. end,
  165. })
  166. minetest.register_craft({
  167. output = mod..":shield_"..name,
  168. recipe = {
  169. {ingredient, ingredient, ingredient},
  170. {ingredient, ingredient, ingredient},
  171. {"", ingredient, ""},
  172. },
  173. })
  174. end
  175. instant_ores.after_use = function(itemstack, user, node)
  176. -- Use this hack instead of the insane default which is impossible to work with.
  177. local tool = itemstack:get_tool_capabilities()
  178. local ndef = minetest.registered_nodes[node.name]
  179. local meta = itemstack:get_meta()
  180. local worn = meta:get_int("worn") or 0
  181. -- Using this hack allows tools to have more than 65535 uses, and still behave correctly.
  182. local uses
  183. if not (ndef and tool) then return end
  184. local wear = 0
  185. if ndef.groups.cracky and tool.groupcaps.cracky then
  186. uses = tool.groupcaps.cracky.uses
  187. wear = (4-ndef.groups.cracky)
  188. elseif ndef.groups.choppy and tool.groupcaps.choppy then
  189. uses = tool.groupcaps.choppy.uses
  190. wear = (4-ndef.groups.choppy)
  191. elseif ndef.groups.crumbly and tool.groupcaps.crumbly then
  192. uses = tool.groupcaps.crumbly.uses
  193. wear = (4-ndef.groups.crumbly)
  194. elseif ndef.groups.snappy and tool.groupcaps.snappy then
  195. uses = tool.groupcaps.snappy.uses
  196. wear = (4-ndef.groups.snappy)
  197. else
  198. return
  199. end
  200. if itemstack:get_wear() ~= math.floor(worn * (65536/uses)) then
  201. -- Something tried to change the wear value, adjust the true value to compensate.
  202. worn = math.floor((uses*itemstack:get_wear()/65536) + 0.5)
  203. end
  204. worn = worn + wear
  205. local breaksound = itemstack:get_definition().sound.breaks
  206. if uses then itemstack:set_wear(math.floor(worn * (65536/uses))) end
  207. if itemstack:get_count() == 0 and breaksound then
  208. minetest.sound_play(breaksound, {pos=user:get_pos(), max_hear_distance=6, gain=0.5})
  209. else
  210. meta:set_int("worn", worn)
  211. end
  212. return itemstack
  213. end
  214. instant_ores.null_function = function() end
  215. instant_ores.register_toolset = function(mod, name, desc, color, level, ingredient, --[[ Parameters after this can be omitted ]] optional_durability, optional_speed, infinite_use)
  216. local durability = optional_durability or (20*level*level*level)
  217. local afteruse = infinite_use and instant_ores.null_function or instant_ores.after_use
  218. local maketool = infinite_use and
  219. function(name, def)
  220. def.stack_max = 1
  221. minetest.register_craftitem(name, def)
  222. end
  223. or minetest.register_tool
  224. if level < 1 then level = 1 end
  225. local speed = optional_speed or level
  226. if speed > 2 then
  227. speed = speed*speed/level -- Correct for maxlevel having an effect on speed
  228. elseif speed < 0.001 then
  229. speed = 0.001
  230. else
  231. speed = speed/level
  232. end
  233. local gcap = {
  234. cracky = {},
  235. crumbly = {},
  236. choppy = {},
  237. snappy = {}
  238. }
  239. gcap.cracky[3] = 2.00/speed
  240. gcap.crumbly[3] = 1.00/speed
  241. gcap.crumbly[2] = 2.40/speed
  242. gcap.crumbly[1] = 3.60/speed
  243. gcap.choppy[3] = 2.60/speed
  244. gcap.choppy[2] = 4.00/speed
  245. gcap.snappy[3] = 0.80 / speed
  246. gcap.snappy[2] = 2.80 / speed
  247. if level > 1 then
  248. gcap.cracky[2] = 4.00 / speed
  249. gcap.choppy[1] = 6.00 /speed
  250. if level > 2 then
  251. gcap.cracky[1] = 6.00 /speed
  252. gcap.snappy[1] = 7.50 /speed
  253. end
  254. end
  255. maketool(":"..mod..":pick_"..name, {
  256. description = desc.." Pickaxe",
  257. inventory_image = "tool_base.png^tool_pick_base.png^(tool_pick.png^[colorize:"..color..")",
  258. tool_capabilities = {
  259. full_punch_interval = 2.67/(optional_speed or level),
  260. max_drop_level=level,
  261. groupcaps={
  262. cracky = {uses=durability, maxlevel=level, times=gcap.cracky},
  263. },
  264. damage_groups = {fleshy=level+1},
  265. },
  266. groups = {pick = 1},
  267. sound = {breaks = "default_tool_breaks"},
  268. after_use = afteruse,
  269. })
  270. minetest.register_craft({
  271. output = mod..":pick_"..name,
  272. recipe = {
  273. {ingredient, ingredient, ingredient},
  274. {"","default:stick",""},
  275. {"","default:stick",""}
  276. }
  277. })
  278. maketool(":"..mod..":shovel_"..name, {
  279. description = desc.." Shovel",
  280. inventory_image = "tool_base.png^tool_shovel_base.png^(tool_shovel.png^[colorize:"..color..")",
  281. wield_image = "tool_base.png^tool_shovel_base.png^(tool_shovel.png^[colorize:"..color..")^[transformR90",
  282. tool_capabilities = {
  283. full_punch_interval = 3/(optional_speed or level),
  284. max_drop_level=level,
  285. groupcaps={
  286. crumbly = {uses=durability, maxlevel=level, times=gcap.crumbly},
  287. },
  288. damage_groups = {fleshy=level},
  289. },
  290. groups = {shovel = 1},
  291. sound = {breaks = "default_tool_breaks"},
  292. after_use = afteruse,
  293. })
  294. minetest.register_craft({
  295. output = mod..":shovel_"..name,
  296. recipe = {
  297. {ingredient},
  298. {"default:stick"},
  299. {"default:stick"}
  300. }
  301. })
  302. maketool(":"..mod..":axe_"..name, {
  303. description = desc.." Axe",
  304. inventory_image = "tool_base.png^tool_axe_base.png^(tool_axe.png^[colorize:"..color..")",
  305. tool_capabilities = {
  306. full_punch_interval = 2.67/(optional_speed or level),
  307. max_drop_level=level,
  308. groupcaps={
  309. choppy={uses=durability, maxlevel=level, times=gcap.choppy},
  310. },
  311. damage_groups = {fleshy=level+2},
  312. },
  313. groups = {axe = 1},
  314. sound = {breaks = "default_tool_breaks"},
  315. after_use = afteruse,
  316. })
  317. minetest.register_craft({
  318. output = mod..":axe_"..name,
  319. recipe = {
  320. {ingredient, ingredient},
  321. {ingredient,"default:stick"},
  322. {"","default:stick"}
  323. }
  324. })
  325. maketool(":"..mod..":sword_"..name, {
  326. description = desc.." Sword",
  327. inventory_image = "tool_base.png^tool_sword_base.png^(tool_sword.png^[colorize:"..color..")",
  328. tool_capabilities = {
  329. full_punch_interval = 2.25/(optional_speed or level),
  330. max_drop_level=level,
  331. groupcaps={
  332. snappy={uses=durability, maxlevel=level, times=gcap.snappy},
  333. },
  334. damage_groups = {fleshy=level+3},
  335. },
  336. groups = {sword = 1},
  337. sound = {breaks = "default_tool_breaks"},
  338. after_use = afteruse,
  339. })
  340. minetest.register_craft({
  341. output = mod..":sword_"..name,
  342. recipe = {
  343. {ingredient},
  344. {ingredient},
  345. {"default:stick"}
  346. }
  347. })
  348. if farming then
  349. farming.register_hoe(mod..":hoe_"..name, {
  350. description = desc.." Hoe",
  351. inventory_image = "tool_base.png^tool_hoe_base.png^(tool_hoe.png^[colorize:"..color..")",
  352. max_uses = durability,
  353. material = ingredient,
  354. groups = {hoe=1},
  355. after_use = afteruse,
  356. })
  357. end
  358. end
  359. instant_ores.register_metal = function(metal)
  360. local name = string.split(metal.name, ":")
  361. if #name ~= 2 then
  362. error("metal.name must be the mod name and the metal name separated by ':'")
  363. end
  364. -- name should be in 'mod:material' format (e.g 'aliens:plutonium', 'minerals_plus:tungsten', 'fairytest:enchanted_steel')
  365. -- Fallbacks for properties that *shouldn't* be omitted
  366. metal.description = metal.description or "Terribly Programmed" -- :P
  367. metal.power = metal.power or 3 -- If someone can't decide how strong to make their metal, make it a bit stronger than steel.
  368. --Properties that can reasonably be omitted, as they're not strictly necessary, and sane defaults exist.
  369. --NOTE: setting a custom image will disable automatic colorization.
  370. metal.lump_image = metal.lump_image or ("metal_lump_base.png^(metal_lump.png^[colorize:"..metal.color..")")
  371. metal.ingot_image = metal.ingot_image or ("default_steel_ingot.png^[colorize:"..metal.color)
  372. metal.ore_image = metal.ore_image or ("default_stone.png^mineral_0_base.png^(mineral_0.png^[colorize:"..metal.color..")")
  373. metal.block_image = metal.block_image or ("default_steel_block.png^[colorize:"..metal.color)
  374. metal.tool_ingredient = metal.tool_ingredient or (metal.name.."_ingot")
  375. metal.hardness = metal.hardness or (metal.power - 1)
  376. local crackiness = 1
  377. if metal.hardness < 3 then
  378. if metal.hardness < 1 then
  379. crackiness = 3
  380. else
  381. crackiness = 4 - metal.hardness
  382. end
  383. end
  384. local groups = {cracky = crackiness, level=metal.hardness}
  385. minetest.register_craftitem(":"..metal.name.."_ingot", {
  386. description = metal.description.." Ingot",
  387. inventory_image = metal.ingot_image,
  388. })
  389. minetest.register_node(":"..metal.name.."block", {
  390. description = metal.description.." Block",
  391. tiles = {metal.block_image},
  392. is_ground_content = false,
  393. groups = table.copy(groups),
  394. sounds = default.node_sound_metal_defaults(),
  395. })
  396. local i = metal.name.."_ingot"
  397. local iii = {i,i,i}
  398. minetest.register_craft({
  399. output = metal.name.."block",
  400. recipe = {iii,iii,iii}
  401. })
  402. minetest.register_craft({
  403. type="shapeless",
  404. output = i.." 9",
  405. recipe = {metal.name.."block"}
  406. })
  407. if not metal.artificial then -- Ore-less metals (like bronze) can disable lumps and ore. This will *NOT* make a recipe for your alloy/special metal/whatever.
  408. --Depth and rarity only needed if ore generated.
  409. metal.depth = metal.depth or 32
  410. metal.rarity = metal.rarity or 11
  411. metal.large_depth = metal.large_depth or 2*metal.depth
  412. minetest.register_craftitem(":"..metal.name.."_lump", {
  413. description = metal.description.." Lump",
  414. inventory_image = metal.lump_image,
  415. })
  416. minetest.register_craft({
  417. type = "cooking",
  418. output = metal.name.."_ingot",
  419. recipe = metal.name.."_lump",
  420. cooktime = metal.cooktime
  421. })
  422. minetest.register_node(":"..name[1]..":stone_with_"..name[2], {
  423. description = metal.description.." Ore",
  424. tiles = {metal.ore_image},
  425. groups = table.copy(groups),
  426. drop = metal.name.."_lump",
  427. sounds = default.node_sound_stone_defaults(),
  428. })
  429. instant_ores.register_gen_ore(
  430. name[1]..":stone_with_"..name[2],
  431. metal.rarity,
  432. --[[ For reference,
  433. 8 = coal (approx)
  434. 12 = copper (approx)
  435. 14 = mese (approx)
  436. Actual scarcity of clusters is this value cubed, but this affects the size of clusters as well.
  437. ]]
  438. -metal.depth,
  439. -metal.large_depth
  440. )
  441. end
  442. if not metal.no_tools then
  443. instant_ores.register_toolset(
  444. name[1],
  445. name[2],
  446. metal.description,
  447. metal.color,
  448. metal.power, -- For reference, 2 is based on the power of stone tools.
  449. metal.tool_ingredient, --Must be a valid item
  450. metal.durability, -- can be nil, will be calculated from power if omitted.
  451. metal.speed,
  452. metal.infinite_uses
  453. )
  454. end
  455. if not metal.no_armor then
  456. instant_ores.register_armorset(name[1], name[2],
  457. metal.description,
  458. metal.color,
  459. metal.power,
  460. metal.tool_ingredient,
  461. metal.armor_durability or metal.durability, -- will be calculated from power if both are nil.
  462. metal.infinite_uses,
  463. metal.shield_damage_sound or "default_dig_metal",
  464. metal.armor_protection,
  465. metal.armor_hurtback,
  466. metal.armor_weight)
  467. end
  468. end
  469. instant_ores.register_crystal = function(crystal)
  470. local name = string.split(crystal.name, ":")
  471. if #name ~= 2 then
  472. error("crystal.name must be the mod name and the crystal name separated by ':'")
  473. end
  474. -- Fallbacks for properties that *shouldn't* be omitted
  475. crystal.description = crystal.description or "Terribly Programmed" -- :P
  476. crystal.power = crystal.power or 3 -- If someone can't decide how strong to make their crystal, make it a bit stronger than steel.
  477. --Properties that can reasonably be omitted, as they're not strictly necessary, and sane defaults exist.
  478. --NOTE: setting a custom image will disable automatic colorization.
  479. crystal.shard_image = crystal.shard_image or ("crystal_shard_base.png^(crystal_shard.png^[colorize:"..crystal.color..")")
  480. crystal.crystal_image = crystal.crystal_image or ("crystal_1_base.png^(crystal_1.png^[colorize:"..crystal.color..")")
  481. crystal.ore_image = crystal.ore_image or ("default_stone.png^mineral_1_base.png^(mineral_1.png^[colorize:"..crystal.color..")")
  482. crystal.block_image = crystal.block_image or ("crystal_block.png^[colorize:"..crystal.color)
  483. crystal.tool_ingredient = crystal.tool_ingredient or (crystal.name.."_crystal")
  484. crystal.hardness = crystal.hardness or (crystal.power - 1)
  485. local crackiness = 1
  486. if crystal.hardness < 3 then
  487. if crystal.hardness < 1 then
  488. crackiness = 3
  489. else
  490. crackiness = 4 - crystal.hardness
  491. end
  492. end
  493. local groups = {cracky = crackiness, level=crystal.hardness}
  494. minetest.register_craftitem(":"..crystal.name.."_crystal", {
  495. description = crystal.description.." Crystal",
  496. inventory_image = crystal.crystal_image,
  497. })
  498. minetest.register_craftitem(":"..crystal.name.."_shard", {
  499. description = crystal.description.." Shard",
  500. inventory_image = crystal.shard_image,
  501. })
  502. minetest.register_node(":"..crystal.name.."block", {
  503. description = crystal.description.." Block",
  504. tiles = {crystal.block_image},
  505. is_ground_content = false,
  506. groups = table.copy(groups),
  507. sounds = default.node_sound_stone_defaults(),
  508. })
  509. local s = crystal.name.."_shard"
  510. local sss = {s,s,s}
  511. local i = crystal.name.."_crystal"
  512. local iii = {i,i,i}
  513. minetest.register_craft({
  514. output = i,
  515. recipe = {sss,sss,sss}
  516. })
  517. minetest.register_craft({
  518. type = "shapeless",
  519. output = s.." 9",
  520. recipe = {i}
  521. })
  522. minetest.register_craft({
  523. output = crystal.name.."block",
  524. recipe = {iii,iii,iii}
  525. })
  526. minetest.register_craft({
  527. type="shapeless",
  528. output = i.." 9",
  529. recipe = {crystal.name.."block"}
  530. })
  531. if not crystal.artificial then -- Ore-less crystals can disable oregen. This will *NOT* make a recipe for your crystal/whatever.
  532. --Depth and rarity only needed if ore generated.
  533. crystal.depth = crystal.depth or 32
  534. crystal.rarity = crystal.rarity or 11
  535. crystal.large_depth = crystal.large_depth or 2*crystal.depth
  536. minetest.register_node(":"..name[1]..":stone_with_"..name[2], {
  537. description = crystal.description.." Ore",
  538. tiles = {crystal.ore_image},
  539. groups = table.copy(groups),
  540. drop = crystal.name.."_crystal",
  541. sounds = default.node_sound_stone_defaults(),
  542. })
  543. instant_ores.register_gen_ore(
  544. name[1]..":stone_with_"..name[2],
  545. crystal.rarity,
  546. --[[ For reference,
  547. 8 = coal (approx)
  548. 12 = copper (approx)
  549. 14 = mese (approx)
  550. Actual scarcity of clusters is this value cubed, but this affects the size of clusters as well.
  551. ]]
  552. -crystal.depth,
  553. -crystal.large_depth
  554. )
  555. end
  556. if not crystal.no_tools then
  557. instant_ores.register_toolset(
  558. name[1],
  559. name[2],
  560. crystal.description,
  561. crystal.color,
  562. crystal.power, -- For reference, 2 is based on the power of stone tools.
  563. crystal.tool_ingredient, --Must be a valid item
  564. crystal.durability, -- can be nil, will be calculated from power if omitted.
  565. crystal.speed,
  566. crystal.infinite_uses
  567. )
  568. end
  569. instant_ores.register_armorset(name[1], name[2],
  570. crystal.description,
  571. crystal.color,
  572. crystal.power,
  573. crystal.tool_ingredient,
  574. crystal.armor_durability or crystal.durability, -- will be calculated from power if both are nil.
  575. crystal.infinite_uses,
  576. crystal.shield_damage_sound or "default_glass_footstep",
  577. crystal.armor_protection,
  578. crystal.armor_hurtback,
  579. crystal.armor_weight)
  580. end
  581. -- test-ores (WARNING: _VERY_ UNBALANCED)
  582. --dofile(minetest.get_modpath("instant_ores").."/examples.lua")