-
Notifications
You must be signed in to change notification settings - Fork 4
/
crafts.lua
81 lines (76 loc) · 2.16 KB
/
crafts.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
local has_technic = minetest.get_modpath("technic")
local has_default = minetest.get_modpath("default")
local has_dye = minetest.get_modpath("dye")
local has_wool = minetest.get_modpath("wool")
local colors = {
white = "#ffffff",
grey = "#888888",
dark_grey = "#444444",
black = "#111111",
violet = "#8000ff",
blue = "#0000ff",
cyan = "#00ffff",
dark_green = "#005900",
green = "#00ff00",
yellow = "#ffff00",
brown = "#592c00",
orange = "#ff7f00",
red = "#ff0000",
magenta = "#ff00ff",
pink = "#ff7f9f",
}
-- Colored grip recipes by overriding item image using metadata
-- Only works for 5.8.0+ clients, but it's purely aesthetic anyway :)
for name, color in pairs(colors) do
local item = ItemStack("wrench:wrench")
item:get_meta():set_string("inventory_image", "wrench_tool.png^(wrench_grip.png^[multiply:"..color..")")
if has_technic and has_dye then
minetest.register_craft({
output = item:to_string(),
recipe = {
{"wrench:wrench", "technic:rubber", "dye:"..name},
}
})
elseif has_wool then
minetest.register_craft({
output = item:to_string(),
recipe = {
{"wrench:wrench", "wool:"..name},
}
})
end
end
-- This is needed to preserve wear when coloring the wrench
minetest.register_on_craft(function(crafted_item, player, old_craft_grid)
if crafted_item:get_name() ~= "wrench:wrench" then
return
end
for _,stack in ipairs(old_craft_grid) do
if stack:get_name() == "wrench:wrench" then
crafted_item:set_wear(stack:get_wear())
return crafted_item
end
end
end)
-- Actual crafting recipe
if minetest.settings:get_bool("wrench.enable_crafting", true) then
if has_technic then
minetest.register_craft({
output = "wrench:wrench",
recipe = {
{"", "technic:stainless_steel_ingot", ""},
{"", "technic:stainless_steel_ingot", "technic:stainless_steel_ingot"},
{"technic:stainless_steel_ingot", "", ""}
}
})
elseif has_default then
minetest.register_craft({
output = "wrench:wrench",
recipe = {
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "", ""},
}
})
end
end