init.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. stack_max = 24,
  53. groups = groups
  54. })
  55. minetest.register_craft({
  56. type = "shapeless",
  57. output = item_name .. " 4",
  58. recipe = {"group:flower,color_" .. name},
  59. })
  60. end
  61. -- Manually add coal->black dye
  62. minetest.register_craft({
  63. type = "shapeless",
  64. output = "dye:black 4",
  65. recipe = {"group:coal"},
  66. })
  67. -- Mix recipes
  68. local dye_recipes = {
  69. -- src1, src2, dst
  70. -- RYB mixes
  71. {"red", "blue", "violet"}, -- "purple"
  72. {"yellow", "red", "orange"},
  73. {"yellow", "blue", "green"},
  74. -- RYB complementary mixes
  75. {"yellow", "violet", "dark_grey"},
  76. {"blue", "orange", "dark_grey"},
  77. -- CMY mixes - approximation
  78. {"cyan", "yellow", "green"},
  79. {"cyan", "magenta", "blue"},
  80. {"yellow", "magenta", "red"},
  81. -- other mixes that result in a color we have
  82. {"red", "green", "brown"},
  83. {"magenta", "blue", "violet"},
  84. {"green", "blue", "cyan"},
  85. {"pink", "violet", "magenta"},
  86. -- mixes with black
  87. {"white", "black", "grey"},
  88. {"grey", "black", "dark_grey"},
  89. {"green", "black", "dark_green"},
  90. {"orange", "black", "brown"},
  91. -- mixes with white
  92. {"white", "red", "pink"},
  93. {"white", "dark_grey", "grey"},
  94. {"white", "dark_green", "green"},
  95. }
  96. for _, mix in pairs(dye_recipes) do
  97. minetest.register_craft({
  98. type = "shapeless",
  99. output = 'dye:' .. mix[3] .. ' 2',
  100. recipe = {'dye:' .. mix[1], 'dye:' .. mix[2]},
  101. })
  102. end