forked from tacotexmex/telemosaic
-
Notifications
You must be signed in to change notification settings - Fork 7
/
extender.lua
98 lines (86 loc) · 2.7 KB
/
extender.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
local S = minetest.get_translator("telemosaic")
local has_dye = minetest.get_modpath("dye")
local function pretty_str(s)
s = string.upper(string.sub(s, 1, 1))..string.sub(s, 2)
local i = string.find(s, "_")
if i then
local c = string.upper(string.sub(s, i + 1, i + 1))
s = string.gsub(s, "_.", " "..c)
end
return s
end
local tiers = {"one", "two", "three"}
for i, range in pairs(telemosaic.extender_ranges) do
local tier = tiers[i]
local common_desc, basic_desc
if has_dye then
common_desc = "Telemosaic Extender, Tier @1 (@2)"
basic_desc = S(common_desc, i, S("Grey"))
else
common_desc = "Telemosaic Extender, Tier @1"
basic_desc = S(common_desc, i)
end
minetest.register_node("telemosaic:extender_"..tier, {
description = basic_desc,
tiles = {
"telemosaic_extender_"..tier..".png"
},
paramtype = "light",
groups = {cracky = 2, telemosaic_extender = range, ["telemosaic_extender_"..tier] = 1},
is_ground_content = false,
after_place_node = telemosaic.extender_place,
after_dig_node = telemosaic.extender_dig,
sounds = default.node_sound_metal_defaults(),
})
if has_dye then
minetest.register_craft({
type = "shapeless",
output = "telemosaic:extender_"..tier,
recipe = {"group:telemosaic_extender_"..tier, "dye:grey"},
})
for name, color in pairs(telemosaic.extender_colors) do
minetest.register_node("telemosaic:extender_"..tier.."_"..name, {
description = S(common_desc, i, S(pretty_str(name))),
tiles = {
"telemosaic_extender_"..tier..".png^[colorize:"..color
},
paramtype = "light",
groups = {
cracky = 2, not_in_creative_inventory = 1,
telemosaic_extender = range, ["telemosaic_extender_"..tier] = 1
},
is_ground_content = false,
after_place_node = telemosaic.extender_place,
after_dig_node = telemosaic.extender_dig,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_craft({
type = "shapeless",
output = "telemosaic:extender_"..tier.."_"..name,
recipe = {"group:telemosaic_extender_"..tier, "dye:"..name},
})
end
end
end
minetest.register_craft({
output = "telemosaic:extender_one",
recipe = {
{"default:obsidian", "doors:door_wood", "default:obsidian"}
}
})
minetest.register_craft({
output = "telemosaic:extender_two",
recipe = {
{"", "group:telemosaic_extender_one", ""},
{"group:telemosaic_extender_one", "default:obsidian", "group:telemosaic_extender_one"},
{"", "group:telemosaic_extender_one", ""}
}
})
minetest.register_craft({
output = "telemosaic:extender_three",
recipe = {
{"", "group:telemosaic_extender_two", ""},
{"group:telemosaic_extender_two", "default:obsidian", "group:telemosaic_extender_two"},
{"", "group:telemosaic_extender_two", ""}
}
})