init.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. -- Other mods can use these for looping through available colors
  2. dye = {}
  3. -- Note: there is another color list in the "bakedclay" mod which must be same
  4. -- as this. Also in the "wool" mod.
  5. local dyes = {
  6. {"white", "White Dye", {dye=1}},
  7. {"grey", "Grey Dye", {dye=1}},
  8. {"dark_grey", "Dark Grey Dye", {dye=1}},
  9. {"black", "Black Dye", {dye=1}},
  10. {"violet", "Violet Dye", {dye=1}},
  11. {"blue", "Blue Dye", {dye=1}},
  12. {"cyan", "Cyan Dye", {dye=1}},
  13. {"dark_green", "Dark Green Dye", {dye=1}},
  14. {"green", "Green Dye", {dye=1}},
  15. {"yellow", "Yellow Dye", {dye=1}},
  16. {"brown", "Brown Dye", {dye=1}},
  17. {"orange", "Orange Dye", {dye=1}},
  18. {"red", "Red Dye", {dye=1}},
  19. {"magenta", "Magenta Dye", {dye=1}},
  20. {"pink", "Pink Dye", {dye=1}},
  21. }
  22. -- Colors which do NOT have corresponding flowers.
  23. -- Also, it's so totally racist to say "blacklist" now.
  24. -- The NPCs can **** ** ***.
  25. local flower_blacklist = {
  26. grey = true,
  27. black = true,
  28. dark_grey = true,
  29. brown = true,
  30. }
  31. -- Define items.
  32. for _, row in ipairs(dyes) do
  33. local name = row[1]
  34. local description = row[2]
  35. local groups = row[3]
  36. local item_name = "dye:" .. name
  37. local item_image = "dye_" .. name .. ".png"
  38. minetest.register_craftitem(item_name, {
  39. inventory_image = item_image,
  40. description = description,
  41. groups = groups,
  42. })
  43. if not flower_blacklist[name] then
  44. minetest.register_craft({
  45. type = "shapeless",
  46. output = item_name .. " 1",
  47. recipe = {"group:flower,color_" .. name, "farming:mortar_pestle"},
  48. replacements = {{"farming:mortar_pestle", "farming:mortar_pestle"}},
  49. })
  50. end
  51. end
  52. -- Manually add coal --> black dye.
  53. minetest.register_craft({
  54. type = "shapeless",
  55. output = "dye:black",
  56. recipe = {"default:coal_lump", "default:clay_lump", "farming:mortar_pestle"},
  57. replacements = {{"farming:mortar_pestle", "farming:mortar_pestle"}},
  58. })
  59. -- Mix recipes. Table params: color1, color2, result.
  60. local dye_recipes = {
  61. -- Basic RYB mixes.
  62. {"red", "blue", "violet" },
  63. {"yellow", "red", "orange" },
  64. {"yellow", "blue", "green" },
  65. -- RYB complementary mixes.
  66. {"yellow", "violet", "dark_grey" },
  67. {"blue", "orange", "dark_grey" },
  68. -- CMY mixes - approximation.
  69. {"cyan", "yellow", "green" },
  70. {"cyan", "magenta", "blue" },
  71. {"yellow", "magenta", "red" },
  72. -- Other mixes that result in a color we have.
  73. {"red", "green", "brown" },
  74. {"magenta", "blue", "violet" },
  75. {"green", "blue", "cyan" },
  76. {"pink", "violet", "magenta" },
  77. -- Mixes with black.
  78. {"white", "black", "grey" },
  79. {"grey", "black", "dark_grey" },
  80. {"green", "black", "dark_green"},
  81. {"orange", "black", "brown" },
  82. -- Mixes with white.
  83. {"white", "red", "pink" },
  84. {"white", "dark_grey", "grey" },
  85. {"white", "dark_green", "green" },
  86. }
  87. for _, mix in ipairs(dye_recipes) do
  88. minetest.register_craft({
  89. type = "shapeless",
  90. output = 'dye:' .. mix[3] .. ' 2',
  91. recipe = {'dye:' .. mix[1], 'dye:' .. mix[2]},
  92. })
  93. end