Skip to content

Commit 15b82f5

Browse files
HybridDogparamat
authored andcommittedJul 1, 2016
Wool: Clean up code
1 parent f796194 commit 15b82f5

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed
 

Diff for: ‎mods/wool/init.lua

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
-- minetest/wool/init.lua
2-
3-
-- Backwards compatibility with jordach's 16-color wool mod
4-
minetest.register_alias("wool:dark_blue", "wool:blue")
5-
minetest.register_alias("wool:gold", "wool:yellow")
6-
7-
local wool = {}
81
-- This uses a trick: you can first define the recipes using all of the base
92
-- colors, and then some recipes using more specific colors for a few non-base
103
-- colors available. When crafting, the last recipes will be checked first.
11-
wool.dyes = {
4+
5+
local dyes = {
126
{"white", "White", "basecolor_white"},
137
{"grey", "Grey", "basecolor_grey"},
148
{"black", "Black", "basecolor_black"},
@@ -26,25 +20,28 @@ wool.dyes = {
2620
{"dark_green", "Dark Green", "unicolor_dark_green"},
2721
}
2822

29-
for _, row in ipairs(wool.dyes) do
30-
local name = row[1]
31-
local desc = row[2]
32-
local craft_color_group = row[3]
33-
-- Node Definition
34-
minetest.register_node("wool:"..name, {
35-
description = desc.." Wool",
36-
tiles = {"wool_"..name..".png"},
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"},
3729
is_ground_content = false,
38-
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3,wool=1},
30+
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
31+
flammable = 3, wool = 1},
3932
sounds = default.node_sound_defaults(),
4033
})
41-
if craft_color_group then
42-
-- Crafting from dye and white wool
43-
minetest.register_craft({
44-
type = "shapeless",
45-
output = 'wool:'..name,
46-
recipe = {'group:dye,'..craft_color_group, 'group:wool'},
47-
})
48-
end
34+
35+
minetest.register_craft{
36+
type = "shapeless",
37+
output = "wool:" .. name,
38+
recipe = {"group:dye," .. craft_color_group, "group:wool"},
39+
}
4940
end
5041

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")

0 commit comments

Comments
 (0)
Please sign in to comment.