init.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. -- dye/init.lua
  2. dye = {}
  3. -- Load support for MT game translation.
  4. local S = minetest.get_translator("dye")
  5. -- Make dye names and descriptions available globally
  6. dye.dyes = {
  7. {"white", "White"},
  8. {"grey", "Grey"},
  9. {"dark_grey", "Dark Grey"},
  10. {"black", "Black"},
  11. {"violet", "Violet"},
  12. {"blue", "Blue"},
  13. {"cyan", "Cyan"},
  14. {"dark_green", "Dark Green"},
  15. {"green", "Green"},
  16. {"yellow", "Yellow"},
  17. {"brown", "Brown"},
  18. {"orange", "Orange"},
  19. {"red", "Red"},
  20. {"magenta", "Magenta"},
  21. {"pink", "Pink"},
  22. }
  23. -- Define items
  24. for _, row in ipairs(dye.dyes) do
  25. local name = row[1]
  26. local description = row[2]
  27. local groups = {dye = 1}
  28. groups["color_" .. name] = 1
  29. minetest.register_craftitem("dye:" .. name, {
  30. inventory_image = "dye_" .. name .. ".png",
  31. description = S(description .. " Dye"),
  32. groups = groups
  33. })
  34. minetest.register_craft({
  35. output = "dye:" .. name .. " 4",
  36. recipe = {
  37. {"group:flower,color_" .. name}
  38. },
  39. })
  40. end
  41. -- Manually add coal -> black dye
  42. minetest.register_craft({
  43. output = "dye:black 4",
  44. recipe = {
  45. {"group:coal"}
  46. },
  47. })
  48. -- Manually add blueberries->violet dye
  49. minetest.register_craft({
  50. output = "dye:violet 2",
  51. recipe = {
  52. {"default:blueberries"}
  53. },
  54. })
  55. -- Mix recipes
  56. local dye_recipes = {
  57. -- src1, src2, dst
  58. -- RYB mixes
  59. {"red", "blue", "violet"}, -- "purple"
  60. {"yellow", "red", "orange"},
  61. {"yellow", "blue", "green"},
  62. -- RYB complementary mixes
  63. {"yellow", "violet", "dark_grey"},
  64. {"blue", "orange", "dark_grey"},
  65. -- CMY mixes - approximation
  66. {"cyan", "yellow", "green"},
  67. {"cyan", "magenta", "blue"},
  68. {"yellow", "magenta", "red"},
  69. -- other mixes that result in a color we have
  70. {"red", "green", "brown"},
  71. {"magenta", "blue", "violet"},
  72. {"green", "blue", "cyan"},
  73. {"pink", "violet", "magenta"},
  74. -- mixes with black
  75. {"white", "black", "grey"},
  76. {"grey", "black", "dark_grey"},
  77. {"green", "black", "dark_green"},
  78. {"orange", "black", "brown"},
  79. -- mixes with white
  80. {"white", "red", "pink"},
  81. {"white", "dark_grey", "grey"},
  82. {"white", "dark_green", "green"},
  83. }
  84. for _, mix in pairs(dye_recipes) do
  85. minetest.register_craft({
  86. type = "shapeless",
  87. output = "dye:" .. mix[3] .. " 2",
  88. recipe = {"dye:" .. mix[1], "dye:" .. mix[2]},
  89. })
  90. end
  91. -- Dummy calls to S() to allow translation scripts to detect the strings.
  92. -- To update this run:
  93. -- for _,e in ipairs(dye.dyes) do print(("S(%q)"):format(e[2].." Dye")) end
  94. --[[
  95. S("White Dye")
  96. S("Grey Dye")
  97. S("Dark Grey Dye")
  98. S("Black Dye")
  99. S("Violet Dye")
  100. S("Blue Dye")
  101. S("Cyan Dye")
  102. S("Dark Green Dye")
  103. S("Green Dye")
  104. S("Yellow Dye")
  105. S("Brown Dye")
  106. S("Orange Dye")
  107. S("Red Dye")
  108. S("Magenta Dye")
  109. S("Pink Dye")
  110. --]]