init.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 4",
  51. recipe = {
  52. {"farming:blueberry", "farming:blueberry"}
  53. },
  54. })
  55. -- Manually add cactus->green dye
  56. minetest.register_craft({
  57. type = "cooking",
  58. cooktime = 6,
  59. output = "dye:green 2",
  60. recipe = "default:cactus"
  61. })
  62. -- Mix recipes
  63. local dye_recipes = {
  64. -- src1, src2, dst
  65. -- RYB mixes
  66. {"red", "blue", "violet"}, -- "purple"
  67. {"yellow", "red", "orange"},
  68. {"yellow", "blue", "green"},
  69. -- RYB complementary mixes
  70. {"yellow", "violet", "dark_grey"},
  71. {"blue", "orange", "dark_grey"},
  72. -- CMY mixes - approximation
  73. {"cyan", "yellow", "green"},
  74. {"cyan", "magenta", "blue"},
  75. {"yellow", "magenta", "red"},
  76. -- other mixes that result in a color we have
  77. {"red", "green", "brown"},
  78. {"magenta", "blue", "violet"},
  79. {"green", "blue", "cyan"},
  80. {"pink", "violet", "magenta"},
  81. -- mixes with black
  82. {"white", "black", "grey"},
  83. {"grey", "black", "dark_grey"},
  84. {"green", "black", "dark_green"},
  85. {"orange", "black", "brown"},
  86. -- mixes with white
  87. {"white", "red", "pink"},
  88. {"white", "dark_grey", "grey"},
  89. {"white", "dark_green", "green"},
  90. }
  91. for _, mix in pairs(dye_recipes) do
  92. minetest.register_craft({
  93. type = "shapeless",
  94. output = "dye:" .. mix[3] .. " 2",
  95. recipe = {"dye:" .. mix[1], "dye:" .. mix[2]},
  96. })
  97. end
  98. -- Dummy calls to S() to allow translation scripts to detect the strings.
  99. -- To update this run:
  100. -- for _,e in ipairs(dye.dyes) do print(("S(%q)"):format(e[2].." Dye")) end
  101. --[[
  102. S("White Dye")
  103. S("Grey Dye")
  104. S("Dark Grey Dye")
  105. S("Black Dye")
  106. S("Violet Dye")
  107. S("Blue Dye")
  108. S("Cyan Dye")
  109. S("Dark Green Dye")
  110. S("Green Dye")
  111. S("Yellow Dye")
  112. S("Brown Dye")
  113. S("Orange Dye")
  114. S("Red Dye")
  115. S("Magenta Dye")
  116. S("Pink Dye")
  117. --]]