init.lua 21 KB

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