init.lua 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. -- minetest/dye/init.lua
  2. -- To make recipes that will work with any dye ever made by anybody, define
  3. -- them based on groups.
  4. -- You can select any group of groups, based on your need for amount of colors.
  5. -- basecolor: 9, excolor: 17, unicolor: 89
  6. --
  7. -- Example of one shapeless recipe using a color group:
  8. -- Note: As this uses basecolor_*, you'd need 9 of these.
  9. -- minetest.register_craft({
  10. -- type = "shapeless",
  11. -- output = '<mod>:item_yellow',
  12. -- recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
  13. -- })
  14. -- Other mods can use these for looping through available colors
  15. local dye = {}
  16. dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"}
  17. dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"}
  18. -- Base color groups:
  19. -- - basecolor_white
  20. -- - basecolor_grey
  21. -- - basecolor_black
  22. -- - basecolor_red
  23. -- - basecolor_yellow
  24. -- - basecolor_green
  25. -- - basecolor_cyan
  26. -- - basecolor_blue
  27. -- - basecolor_magenta
  28. -- Extended color groups (* = equal to a base color):
  29. -- * excolor_white
  30. -- - excolor_lightgrey
  31. -- * excolor_grey
  32. -- - excolor_darkgrey
  33. -- * excolor_black
  34. -- * excolor_red
  35. -- - excolor_orange
  36. -- * excolor_yellow
  37. -- - excolor_lime
  38. -- * excolor_green
  39. -- - excolor_aqua
  40. -- * excolor_cyan
  41. -- - excolor_sky_blue
  42. -- * excolor_blue
  43. -- - excolor_violet
  44. -- * excolor_magenta
  45. -- - excolor_red_violet
  46. -- The whole unifieddyes palette as groups:
  47. -- - unicolor_<excolor>
  48. -- For the following, no white/grey/black is allowed:
  49. -- - unicolor_medium_<excolor>
  50. -- - unicolor_dark_<excolor>
  51. -- - unicolor_light_<excolor>
  52. -- - unicolor_<excolor>_s50
  53. -- - unicolor_medium_<excolor>_s50
  54. -- - unicolor_dark_<excolor>_s50
  55. -- Local stuff
  56. local dyelocal = {}
  57. -- This collection of colors is partly a historic thing, partly something else.
  58. dyelocal.dyes = {
  59. {"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}},
  60. {"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}},
  61. {"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}},
  62. {"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}},
  63. {"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}},
  64. {"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}},
  65. {"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}},
  66. {"dark_green", "Dark green dye",{dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}},
  67. {"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}},
  68. {"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}},
  69. {"brown", "Brown dye", {dye=1, basecolor_yellow=1, excolor_orange=1, unicolor_dark_orange=1}},
  70. {"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}},
  71. {"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}},
  72. {"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1}},
  73. {"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}},
  74. }
  75. -- Define items
  76. for _, row in ipairs(dyelocal.dyes) do
  77. local name = row[1]
  78. local description = row[2]
  79. local groups = row[3]
  80. local item_name = "dye:"..name
  81. local item_image = "dye_"..name..".png"
  82. minetest.register_craftitem(item_name, {
  83. inventory_image = item_image,
  84. description = description,
  85. groups = groups
  86. })
  87. minetest.register_craft({
  88. type = "shapeless",
  89. output = item_name.." 4",
  90. recipe = {"group:flower,color_"..name},
  91. })
  92. end
  93. -- Mix recipes
  94. -- Just mix everything to everything somehow sanely
  95. dyelocal.mixbases = {"magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"}
  96. dyelocal.mixes = {
  97. -- magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white
  98. white = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet", "grey", "grey", "white", "white"},
  99. grey = {"pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "pink", "dark_grey","grey", "grey"},
  100. dark_grey={"brown","brown", "brown", "brown", "brown","dark_green","dark_green","blue","blue","violet","black", "black"},
  101. black = {"black", "black", "black", "black", "black", "black", "black", "black", "black", "black", "black"},
  102. violet= {"magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"},
  103. blue = {"violet", "magenta","brown","brown","dark_green","cyan","cyan", "cyan", "blue"},
  104. cyan = {"blue","brown","dark_green","dark_grey","green","cyan","dark_green","cyan"},
  105. dark_green={"brown","brown","brown", "brown", "green", "green", "dark_green"},
  106. green = {"brown", "yellow","yellow","dark_green","green","green"},
  107. yellow= {"red", "orange", "yellow","orange", "yellow"},
  108. brown = {"brown", "brown","orange", "brown"},
  109. orange= {"red", "orange","orange"},
  110. red = {"magenta","red"},
  111. magenta={"magenta"},
  112. }
  113. for one,results in pairs(dyelocal.mixes) do
  114. for i,result in ipairs(results) do
  115. local another = dyelocal.mixbases[i]
  116. minetest.register_craft({
  117. type = "shapeless",
  118. output = 'dye:'..result..' 2',
  119. recipe = {'dye:'..one, 'dye:'..another},
  120. })
  121. end
  122. end
  123. -- Hide dyelocal
  124. dyelocal = nil
  125. -- EOF