init.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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 minetest.get_modpath("toolranks") then
  349. toolranks.add_tool(mod..":pick_"..name)
  350. toolranks.add_tool(mod..":shovel_"..name)
  351. toolranks.add_tool(mod..":axe_"..name)
  352. toolranks.add_tool(mod..":sword_"..name)
  353. end
  354. if farming then
  355. farming.register_hoe(mod..":hoe_"..name, {
  356. description = desc.." Hoe",
  357. inventory_image = "tool_base.png^tool_hoe_base.png^(tool_hoe.png^[colorize:"..color..")",
  358. max_uses = durability,
  359. material = ingredient,
  360. groups = {hoe=1},
  361. after_use = afteruse,
  362. })
  363. if minetest.get_modpath("toolranks") then
  364. toolranks.add_tool(mod..":hoe_"..name)
  365. end
  366. end
  367. end
  368. instant_ores.register_metal = function(metal)
  369. local name = string.split(metal.name, ":")
  370. if #name ~= 2 then
  371. error("metal.name must be the mod name and the metal name separated by ':'")
  372. end
  373. -- name should be in 'mod:material' format (e.g 'aliens:plutonium', 'minerals_plus:tungsten', 'fairytest:enchanted_steel')
  374. -- Fallbacks for properties that *shouldn't* be omitted
  375. metal.description = metal.description or "Terribly Programmed" -- :P
  376. metal.power = metal.power or 3 -- If someone can't decide how strong to make their metal, make it a bit stronger than steel.
  377. --Properties that can reasonably be omitted, as they're not strictly necessary, and sane defaults exist.
  378. --NOTE: setting a custom image will disable automatic colorization.
  379. metal.lump_image = metal.lump_image or ("metal_lump_base.png^(metal_lump.png^[colorize:"..metal.color..")")
  380. metal.ingot_image = metal.ingot_image or ("default_steel_ingot.png^[colorize:"..metal.color)
  381. metal.ore_image = metal.ore_image or ("default_stone.png^mineral_0_base.png^(mineral_0.png^[colorize:"..metal.color..")")
  382. metal.block_image = metal.block_image or ("default_steel_block.png^[colorize:"..metal.color)
  383. metal.tool_ingredient = metal.tool_ingredient or (metal.name.."_ingot")
  384. metal.hardness = metal.hardness or (metal.power - 1)
  385. local crackiness = 1
  386. if metal.hardness < 3 then
  387. if metal.hardness < 1 then
  388. crackiness = 3
  389. else
  390. crackiness = 4 - metal.hardness
  391. end
  392. end
  393. local groups = {cracky = crackiness, level=metal.hardness}
  394. minetest.register_craftitem(":"..metal.name.."_ingot", {
  395. description = metal.description.." Ingot",
  396. inventory_image = metal.ingot_image,
  397. })
  398. minetest.register_node(":"..metal.name.."block", {
  399. description = metal.description.." Block",
  400. tiles = {metal.block_image},
  401. is_ground_content = false,
  402. groups = table.copy(groups),
  403. sounds = default.node_sound_metal_defaults(),
  404. })
  405. local i = metal.name.."_ingot"
  406. local iii = {i,i,i}
  407. minetest.register_craft({
  408. output = metal.name.."block",
  409. recipe = {iii,iii,iii}
  410. })
  411. minetest.register_craft({
  412. type="shapeless",
  413. output = i.." 9",
  414. recipe = {metal.name.."block"}
  415. })
  416. 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.
  417. --Depth and rarity only needed if ore generated.
  418. metal.depth = metal.depth or 32
  419. metal.rarity = metal.rarity or 11
  420. metal.large_depth = metal.large_depth or 2*metal.depth
  421. minetest.register_craftitem(":"..metal.name.."_lump", {
  422. description = metal.description.." Lump",
  423. inventory_image = metal.lump_image,
  424. })
  425. minetest.register_craft({
  426. type = "cooking",
  427. output = metal.name.."_ingot",
  428. recipe = metal.name.."_lump",
  429. cooktime = metal.cooktime
  430. })
  431. minetest.register_node(":"..name[1]..":stone_with_"..name[2], {
  432. description = metal.description.." Ore",
  433. tiles = {metal.ore_image},
  434. groups = table.copy(groups),
  435. drop = metal.name.."_lump",
  436. sounds = default.node_sound_stone_defaults(),
  437. })
  438. instant_ores.register_gen_ore(
  439. name[1]..":stone_with_"..name[2],
  440. metal.rarity,
  441. --[[ For reference,
  442. 8 = coal (approx)
  443. 12 = copper (approx)
  444. 14 = mese (approx)
  445. Actual scarcity of clusters is this value cubed, but this affects the size of clusters as well.
  446. ]]
  447. -metal.depth,
  448. -metal.large_depth
  449. )
  450. end
  451. if not metal.no_tools then
  452. instant_ores.register_toolset(
  453. name[1],
  454. name[2],
  455. metal.description,
  456. metal.color,
  457. metal.power, -- For reference, 2 is based on the power of stone tools.
  458. metal.tool_ingredient, --Must be a valid item
  459. metal.durability, -- can be nil, will be calculated from power if omitted.
  460. metal.speed,
  461. metal.infinite_uses
  462. )
  463. end
  464. if not metal.no_armor then
  465. instant_ores.register_armorset(name[1], name[2],
  466. metal.description,
  467. metal.color,
  468. metal.power,
  469. metal.tool_ingredient,
  470. metal.armor_durability or metal.durability, -- will be calculated from power if both are nil.
  471. metal.infinite_uses,
  472. metal.shield_damage_sound or "default_dig_metal",
  473. metal.armor_protection,
  474. metal.armor_hurtback,
  475. metal.armor_weight)
  476. end
  477. end
  478. instant_ores.register_crystal = function(crystal)
  479. local name = string.split(crystal.name, ":")
  480. if #name ~= 2 then
  481. error("crystal.name must be the mod name and the crystal name separated by ':'")
  482. end
  483. -- Fallbacks for properties that *shouldn't* be omitted
  484. crystal.description = crystal.description or "Terribly Programmed" -- :P
  485. crystal.power = crystal.power or 3 -- If someone can't decide how strong to make their crystal, make it a bit stronger than steel.
  486. --Properties that can reasonably be omitted, as they're not strictly necessary, and sane defaults exist.
  487. --NOTE: setting a custom image will disable automatic colorization.
  488. crystal.shard_image = crystal.shard_image or ("crystal_shard_base.png^(crystal_shard.png^[colorize:"..crystal.color..")")
  489. crystal.crystal_image = crystal.crystal_image or ("crystal_1_base.png^(crystal_1.png^[colorize:"..crystal.color..")")
  490. crystal.ore_image = crystal.ore_image or ("default_stone.png^mineral_1_base.png^(mineral_1.png^[colorize:"..crystal.color..")")
  491. crystal.block_image = crystal.block_image or ("crystal_block.png^[colorize:"..crystal.color)
  492. crystal.tool_ingredient = crystal.tool_ingredient or (crystal.name.."_crystal")
  493. crystal.hardness = crystal.hardness or (crystal.power - 1)
  494. local crackiness = 1
  495. if crystal.hardness < 3 then
  496. if crystal.hardness < 1 then
  497. crackiness = 3
  498. else
  499. crackiness = 4 - crystal.hardness
  500. end
  501. end
  502. local groups = {cracky = crackiness, level=crystal.hardness}
  503. minetest.register_craftitem(":"..crystal.name.."_crystal", {
  504. description = crystal.description.." Crystal",
  505. inventory_image = crystal.crystal_image,
  506. })
  507. minetest.register_craftitem(":"..crystal.name.."_shard", {
  508. description = crystal.description.." Shard",
  509. inventory_image = crystal.shard_image,
  510. })
  511. minetest.register_node(":"..crystal.name.."block", {
  512. description = crystal.description.." Block",
  513. tiles = {crystal.block_image},
  514. is_ground_content = false,
  515. groups = table.copy(groups),
  516. sounds = default.node_sound_stone_defaults(),
  517. })
  518. local s = crystal.name.."_shard"
  519. local sss = {s,s,s}
  520. local i = crystal.name.."_crystal"
  521. local iii = {i,i,i}
  522. minetest.register_craft({
  523. output = i,
  524. recipe = {sss,sss,sss}
  525. })
  526. minetest.register_craft({
  527. type = "shapeless",
  528. output = s.." 9",
  529. recipe = {i}
  530. })
  531. minetest.register_craft({
  532. output = crystal.name.."block",
  533. recipe = {iii,iii,iii}
  534. })
  535. minetest.register_craft({
  536. type="shapeless",
  537. output = i.." 9",
  538. recipe = {crystal.name.."block"}
  539. })
  540. if not crystal.artificial then -- Ore-less crystals can disable oregen. This will *NOT* make a recipe for your crystal/whatever.
  541. --Depth and rarity only needed if ore generated.
  542. crystal.depth = crystal.depth or 32
  543. crystal.rarity = crystal.rarity or 11
  544. crystal.large_depth = crystal.large_depth or 2*crystal.depth
  545. minetest.register_node(":"..name[1]..":stone_with_"..name[2], {
  546. description = crystal.description.." Ore",
  547. tiles = {crystal.ore_image},
  548. groups = table.copy(groups),
  549. drop = crystal.name.."_crystal",
  550. sounds = default.node_sound_stone_defaults(),
  551. })
  552. instant_ores.register_gen_ore(
  553. name[1]..":stone_with_"..name[2],
  554. crystal.rarity,
  555. --[[ For reference,
  556. 8 = coal (approx)
  557. 12 = copper (approx)
  558. 14 = mese (approx)
  559. Actual scarcity of clusters is this value cubed, but this affects the size of clusters as well.
  560. ]]
  561. -crystal.depth,
  562. -crystal.large_depth
  563. )
  564. end
  565. if not crystal.no_tools then
  566. instant_ores.register_toolset(
  567. name[1],
  568. name[2],
  569. crystal.description,
  570. crystal.color,
  571. crystal.power, -- For reference, 2 is based on the power of stone tools.
  572. crystal.tool_ingredient, --Must be a valid item
  573. crystal.durability, -- can be nil, will be calculated from power if omitted.
  574. crystal.speed,
  575. crystal.infinite_uses
  576. )
  577. end
  578. instant_ores.register_armorset(name[1], name[2],
  579. crystal.description,
  580. crystal.color,
  581. crystal.power,
  582. crystal.tool_ingredient,
  583. crystal.armor_durability or crystal.durability, -- will be calculated from power if both are nil.
  584. crystal.infinite_uses,
  585. crystal.shield_damage_sound or "default_glass_footstep",
  586. crystal.armor_protection,
  587. crystal.armor_hurtback,
  588. crystal.armor_weight)
  589. end
  590. -- test-ores (WARNING: _VERY_ UNBALANCED)
  591. --dofile(minetest.get_modpath("instant_ores").."/examples.lua")