init.lua 4.0 KB

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