init.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. -- Other mods can use these for looping through available colors
  2. dye = {}
  3. dye.basecolors = {
  4. "white" ,
  5. "grey" ,
  6. "black" ,
  7. "red" ,
  8. "yellow" ,
  9. "green" ,
  10. "cyan" ,
  11. "blue" ,
  12. "magenta" ,
  13. }
  14. dye.excolors = {
  15. "white" ,
  16. "lightgrey" ,
  17. "grey" ,
  18. "darkgrey" ,
  19. "black" ,
  20. "red" ,
  21. "orange" ,
  22. "yellow" ,
  23. "lime" ,
  24. "green" ,
  25. "aqua" ,
  26. "cyan" ,
  27. "sky_blue" ,
  28. "blue" ,
  29. "violet" ,
  30. "magenta" ,
  31. "red_violet" ,
  32. }
  33. -- Make dye names and descriptions available globally.
  34. -- Note: there is another color list in the bakedclay mod which must be same as this.
  35. dye.dyes = {
  36. {"white", "White"},
  37. {"grey", "Grey"},
  38. {"dark_grey", "Dark Grey"},
  39. {"black", "Black"},
  40. {"violet", "Violet"},
  41. {"blue", "Blue"},
  42. {"cyan", "Cyan"},
  43. {"dark_green", "Dark Green"},
  44. {"green", "Green"},
  45. {"yellow", "Yellow"},
  46. {"brown", "Brown"},
  47. {"orange", "Orange"},
  48. {"red", "Red"},
  49. {"magenta", "Magenta"},
  50. {"pink", "Pink"},
  51. }
  52. -- This collection of colors is partly a historic thing, partly something else.
  53. local dyes = {
  54. {"white", "White Dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
  55. {"grey", "Grey Dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
  56. {"dark_grey", "Dark Grey Dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
  57. {"black", "Black Dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}},
  58. {"violet", "Violet Dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
  59. {"blue", "Blue Dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
  60. {"cyan", "Cyan Dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
  61. {"dark_green", "Dark Green Dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
  62. {"green", "Green Dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
  63. {"yellow", "Yellow Dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
  64. {"brown", "Brown Dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}},
  65. {"orange", "Orange Dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
  66. {"red", "Red Dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
  67. {"magenta", "Magenta Dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1, unicolor_red_violet=1}},
  68. {"pink", "Pink Dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
  69. }
  70. -- Define items.
  71. for _, row in ipairs(dyes) do
  72. local name = row[1]
  73. local description = row[2]
  74. local groups = row[3]
  75. local item_name = "dye:" .. name
  76. local item_image = "dye_" .. name .. ".png"
  77. minetest.register_craftitem(item_name, {
  78. inventory_image = item_image,
  79. description = description,
  80. groups = groups,
  81. })
  82. minetest.register_craft({
  83. type = "shapeless",
  84. output = item_name .. " 1",
  85. recipe = {"group:flower,color_" .. name},
  86. })
  87. end
  88. -- Manually add coal --> black dye.
  89. minetest.register_craft({
  90. type = "shapeless",
  91. output = "dye:black",
  92. recipe = {"default:coal_lump", "default:clay_lump"},
  93. })
  94. -- Mix recipes.
  95. local dye_recipes = {
  96. -- Table params: color1, color2, result.
  97. -- Basic RYB mixes.
  98. {"red", "blue", "violet" }, -- "purple"
  99. {"yellow", "red", "orange" },
  100. {"yellow", "blue", "green" },
  101. -- RYB complementary mixes.
  102. {"yellow", "violet", "dark_grey" },
  103. {"blue", "orange", "dark_grey" },
  104. -- CMY mixes - approximation.
  105. {"cyan", "yellow", "green" },
  106. {"cyan", "magenta", "blue" },
  107. {"yellow", "magenta", "red" },
  108. -- Other mixes that result in a color we have.
  109. {"red", "green", "brown" },
  110. {"magenta", "blue", "violet" },
  111. {"green", "blue", "cyan" },
  112. {"pink", "violet", "magenta" },
  113. -- Mixes with black.
  114. {"white", "black", "grey" },
  115. {"grey", "black", "dark_grey" },
  116. {"green", "black", "dark_green"},
  117. {"orange", "black", "brown" },
  118. -- Mixes with white.
  119. {"white", "red", "pink" },
  120. {"white", "dark_grey", "grey" },
  121. {"white", "dark_green", "green" },
  122. }
  123. for _, mix in ipairs(dye_recipes) do
  124. minetest.register_craft({
  125. type = "shapeless",
  126. output = 'dye:' .. mix[3] .. ' 2',
  127. recipe = {'dye:' .. mix[1], 'dye:' .. mix[2]},
  128. })
  129. end