Show title and author of book in description
[oweals/minetest_game.git] / mods / wool / init.lua
1 -- This uses a trick: you can first define the recipes using all of the base
2 -- colors, and then some recipes using more specific colors for a few non-base
3 -- colors available. When crafting, the last recipes will be checked first.
4
5 local dyes = {
6         {"white",      "White",      "basecolor_white"},
7         {"grey",       "Grey",       "basecolor_grey"},
8         {"black",      "Black",      "basecolor_black"},
9         {"red",        "Red",        "basecolor_red"},
10         {"yellow",     "Yellow",     "basecolor_yellow"},
11         {"green",      "Green",      "basecolor_green"},
12         {"cyan",       "Cyan",       "basecolor_cyan"},
13         {"blue",       "Blue",       "basecolor_blue"},
14         {"magenta",    "Magenta",    "basecolor_magenta"},
15         {"orange",     "Orange",     "excolor_orange"},
16         {"violet",     "Violet",     "excolor_violet"},
17         {"brown",      "Brown",      "unicolor_dark_orange"},
18         {"pink",       "Pink",       "unicolor_light_red"},
19         {"dark_grey",  "Dark Grey",  "unicolor_darkgrey"},
20         {"dark_green", "Dark Green", "unicolor_dark_green"},
21 }
22
23 for i = 1, #dyes do
24         local name, desc, craft_color_group = unpack(dyes[i])
25
26         minetest.register_node("wool:" .. name, {
27                 description = desc .. " Wool",
28                 tiles = {"wool_" .. name .. ".png"},
29                 is_ground_content = false,
30                 groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
31                                 flammable = 3, wool = 1},
32                 sounds = default.node_sound_defaults(),
33         })
34
35         minetest.register_craft{
36                 type = "shapeless",
37                 output = "wool:" .. name,
38                 recipe = {"group:dye," .. craft_color_group, "group:wool"},
39         }
40 end
41
42
43 -- legacy
44
45 -- Backwards compatibility with jordach's 16-color wool mod
46 minetest.register_alias("wool:dark_blue", "wool:blue")
47 minetest.register_alias("wool:gold", "wool:yellow")