init.lua 2.5 KB

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