init.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. dye = {}
  2. -- Make dye names and descriptions available globally
  3. dye.dyes = {
  4. {"white", "White"},
  5. {"grey", "Grey"},
  6. {"dark_grey", "Dark grey"},
  7. {"black", "Black"},
  8. {"violet", "Violet"},
  9. {"blue", "Blue"},
  10. {"cyan", "Cyan"},
  11. {"dark_green", "Dark green"},
  12. {"green", "Green"},
  13. {"yellow", "Yellow"},
  14. {"brown", "Brown"},
  15. {"orange", "Orange"},
  16. {"red", "Red"},
  17. {"magenta", "Magenta"},
  18. {"pink", "Pink"},
  19. }
  20. -- Define items
  21. for _, row in ipairs(dye.dyes) do
  22. local name = row[1]
  23. local description = row[2]
  24. local groups = {dye = 1}
  25. groups["color_" .. name] = 1
  26. minetest.register_craftitem("dye:" .. name, {
  27. inventory_image = "dye_" .. name .. ".png",
  28. description = description .. " Dye",
  29. groups = groups
  30. })
  31. minetest.register_craft({
  32. output = "dye:" .. name .. " 4",
  33. recipe = {
  34. {"group:flower,color_" .. name}
  35. },
  36. })
  37. end
  38. -- Manually add coal -> black dye
  39. minetest.register_craft({
  40. output = "dye:black 4",
  41. recipe = {
  42. {"group:coal"}
  43. },
  44. })
  45. -- Manually add blueberries->violet dye
  46. minetest.register_craft({
  47. output = "dye:violet 2",
  48. recipe = {
  49. {"default:blueberries"}
  50. },
  51. })
  52. -- Mix recipes
  53. local dye_recipes = {
  54. -- src1, src2, dst
  55. -- RYB mixes
  56. {"red", "blue", "violet"}, -- "purple"
  57. {"yellow", "red", "orange"},
  58. {"yellow", "blue", "green"},
  59. -- RYB complementary mixes
  60. {"yellow", "violet", "dark_grey"},
  61. {"blue", "orange", "dark_grey"},
  62. -- CMY mixes - approximation
  63. {"cyan", "yellow", "green"},
  64. {"cyan", "magenta", "blue"},
  65. {"yellow", "magenta", "red"},
  66. -- other mixes that result in a color we have
  67. {"red", "green", "brown"},
  68. {"magenta", "blue", "violet"},
  69. {"green", "blue", "cyan"},
  70. {"pink", "violet", "magenta"},
  71. -- mixes with black
  72. {"white", "black", "grey"},
  73. {"grey", "black", "dark_grey"},
  74. {"green", "black", "dark_green"},
  75. {"orange", "black", "brown"},
  76. -- mixes with white
  77. {"white", "red", "pink"},
  78. {"white", "dark_grey", "grey"},
  79. {"white", "dark_green", "green"},
  80. }
  81. for _, mix in pairs(dye_recipes) do
  82. minetest.register_craft({
  83. type = "shapeless",
  84. output = 'dye:' .. mix[3] .. ' 2',
  85. recipe = {'dye:' .. mix[1], 'dye:' .. mix[2]},
  86. })
  87. end