init.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. unique_ores = {}
  2. unique_ores.debug = false
  3. unique_ores.names = {
  4. {
  5. {"az","Az","vibrant"},
  6. {"xor","Xor","grey"},
  7. {"upsid","Upsid","grey"},
  8. {"lux","Lux","vibrant"},
  9. {"magn","Magn","grey"},
  10. {"aur","Aur","vibrant"},
  11. {"noct","Noct","dark"},
  12. {"byzant","Byzant","dark"},
  13. {"tyr","Tyr","dark"},
  14. },
  15. {
  16. strong = {
  17. {"an","red"},
  18. {"on","red"},
  19. {"az","purple"},
  20. {"iz","green"},
  21. {"ul","blue"},
  22. {"umin","blue"},
  23. {"olith","silver"},
  24. },
  25. regular = {
  26. {"in","brown"},
  27. {"oc","yellow"},
  28. {"al","blue"},
  29. {"","silver"},
  30. }
  31. },
  32. {
  33. {"ium",instant_ores.register_metal,"durable"},
  34. {"ite",instant_ores.register_metal,"fast"},
  35. {"on",instant_ores.register_crystal,"durable"},
  36. {"ine",instant_ores.register_crystal,"fast"},
  37. },
  38. }
  39. unique_ores.colors = {
  40. vibrant={
  41. red="#C00:140",
  42. purple="#A0D:160",
  43. green="#1C1:140",
  44. blue="#00C:140",
  45. silver="#DDD:100",
  46. brown="#860:140",
  47. yellow="#DB0:140",
  48. },
  49. dark = {
  50. red="#400:160",
  51. purple="#404:160",
  52. green="#040:160",
  53. blue="#004:160",
  54. silver="#000:180",
  55. brown="#401800:160",
  56. yellow="#440:160",
  57. },
  58. grey = {
  59. red="#623:96",
  60. purple="#757:96",
  61. green="#474:96",
  62. blue="#246:96",
  63. silver="#CCC:128",
  64. brown="#764:96",
  65. yellow="#984:110",
  66. },
  67. }
  68. unique_ores.magical_noisemaker = PerlinNoise(tonumber(minetest.get_mapgen_setting("seed"))%100000000, 12, 2, 1000)
  69. local worldrand = function(n)
  70. return math.abs(math.floor(unique_ores.magical_noisemaker:get2d({x=n*200,y=-200})))
  71. end
  72. local strong_prefix = unique_ores.names[1][(worldrand(1) % #(unique_ores.names[1]))+1]
  73. local strong_middle = unique_ores.names[2].strong[(worldrand(2) % #(unique_ores.names[2].strong))+1]
  74. local strong_suffix = unique_ores.names[3][(worldrand(3) % #(unique_ores.names[3]))+1]
  75. local regular_prefix = unique_ores.names[1][(worldrand(4) % #(unique_ores.names[1]))+1]
  76. local regular_middle = unique_ores.names[2].regular[(worldrand(5) % #(unique_ores.names[2].regular))+1]
  77. local regular_suffix = unique_ores.names[3][(worldrand(6) % #(unique_ores.names[3]))+1]
  78. strong_suffix[2]({
  79. name = "unique_ores:"..strong_prefix[1]..strong_middle[1]..strong_suffix[1],
  80. description = strong_prefix[2]..strong_middle[1]..strong_suffix[1],
  81. color = unique_ores.colors[strong_prefix[3] ][strong_middle[2] ],
  82. power = 3,
  83. speed = 3 + ((strong_suffix[3] == "fast") and 0.25 or 0),
  84. depth = 128,
  85. rarity = 16,
  86. durability = 250 + ((strong_suffix[3] == "durable") and 300 or 0),
  87. })
  88. regular_suffix[2]({
  89. name = "unique_ores:"..regular_prefix[1]..regular_middle[1]..regular_suffix[1],
  90. description = regular_prefix[2]..regular_middle[1]..regular_suffix[1],
  91. color = unique_ores.colors[regular_prefix[3] ][regular_middle[2] ],
  92. power = 2,
  93. speed = 2.25+((regular_suffix[3] == "fast") and 0.5 or 0),
  94. depth = 32,
  95. rarity = 13,
  96. durability = 128 + ((regular_suffix[3] == "durable") and 192 or 0),
  97. })
  98. -- Keep track of the names, so that other mods can still make an attempt to work with us,
  99. -- even though we are literally the most insane and unpredictable mod in all of minetest.
  100. unique_ores.strong_material = "unique_ores:"..strong_prefix[1]..strong_middle[1]..strong_suffix[1]
  101. unique_ores.regular_material = "unique_ores:"..regular_prefix[1]..regular_middle[1]..regular_suffix[1]
  102. if unique_ores.debug then
  103. minetest.after(10, minetest.chat_send_all,
  104. (tonumber(minetest.get_mapgen_setting("seed"))%100000000) .." ".. worldrand(1) .." ".. worldrand(2) .." ".. worldrand(3) .." ".. worldrand(4) .." ".. worldrand(5) .." ".. worldrand(6)
  105. )
  106. end