init.lua 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. -- minetest/dye/init.lua
  2. -- Other mods can use these for looping through available colors
  3. dye = {}
  4. dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"}
  5. dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"}
  6. -- This collection of colors is partly a historic thing, partly something else.
  7. dyes = {
  8. {"white", "White Dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
  9. {"grey", "Grey Dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
  10. {"dark_grey", "Dark grey Dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
  11. {"black", "Black Dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}},
  12. {"violet", "Violet Dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
  13. {"blue", "Blue Dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
  14. {"cyan", "Cyan Dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
  15. {"dark_green", "Dark green Dye",{dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
  16. {"green", "Green Dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
  17. {"yellow", "Yellow Dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
  18. {"brown", "Brown Dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}},
  19. {"orange", "Orange Dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
  20. {"red", "Red Dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
  21. {"magenta", "Magenta Dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}},
  22. {"pink", "Pink Dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
  23. }
  24. -- Define items
  25. for _, row in ipairs(dyes) do
  26. local name = row[1]
  27. local description = row[2]
  28. local groups = row[3]
  29. local item_name = "dye:"..name
  30. local item_image = "dye_"..name..".png"
  31. minetest.register_craftitem(item_name, {
  32. inventory_image = item_image,
  33. description = description,
  34. groups = groups
  35. })
  36. minetest.register_craft({
  37. type = "shapeless",
  38. output = item_name.." 4",
  39. recipe = {"group:flower,color_"..name},
  40. })
  41. end
  42. -- Special case
  43. minetest.register_craft({
  44. type = "shapeless",
  45. output = "dye:black 4",
  46. recipe = {"default:coal_lump"},
  47. })
  48. minetest.register_craft({
  49. type = "shapeless",
  50. output = "dye:cyan 4",
  51. recipe = {"default:copper_lump"},
  52. })
  53. -- Mix recipes
  54. -- Just mix everything to everything somehow sanely
  55. mixbases = {"magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"}
  56. mixes = {
  57. -- magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white
  58. white = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet", "grey", "grey", "white", "white"},
  59. grey = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "pink", "dark_grey","grey", "grey"},
  60. dark_grey={"brown","brown", "brown", "brown", "brown","dark_green","dark_green","blue","blue","violet","black", "black"},
  61. black = {"black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black"},
  62. violet= {"magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"},
  63. blue = {"violet", "magenta","brown","brown","dark_green","cyan","cyan", "cyan", "blue"},
  64. cyan = {"blue","brown","dark_green","dark_grey","green","cyan","dark_green","cyan"},
  65. dark_green={"brown","brown","brown", "brown", "green", "green", "dark_green"},
  66. green = {"brown", "yellow","yellow","dark_green","green","green"},
  67. yellow= {"red", "orange", "yellow","orange", "yellow"},
  68. brown = {"brown", "brown","orange", "brown"},
  69. orange= {"red", "orange","orange"},
  70. red = {"magenta","red"},
  71. magenta={"magenta"},
  72. }
  73. for one,results in pairs(mixes) do
  74. for i,result in ipairs(results) do
  75. local another = mixbases[i]
  76. minetest.register_craft({
  77. type = "shapeless",
  78. output = 'dye:'..result..' 2',
  79. recipe = {'dye:'..one, 'dye:'..another},
  80. })
  81. end
  82. end