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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
-- Minetest 0.4.7 mod: framedglass
minetest.register_craft({
output = 'framedglass:wooden_framed_glass 4',
recipe = {
{'default:glass', 'default:glass', 'default:stick'},
{'default:glass', 'default:glass', 'default:stick'},
{'default:stick', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'framedglass:steel_framed_glass 4',
recipe = {
{'default:glass', 'default:glass', 'default:steel_ingot'},
{'default:glass', 'default:glass', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', ''},
}
})
minetest.register_craft({
output = 'framedglass:wooden_framed_obsidian_glass 4',
recipe = {
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
{'default:stick', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'framedglass:steel_framed_obsidian_glass 4',
recipe = {
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', ''},
}
})
minetest.register_node("framedglass:wooden_framed_glass", {
description = "Wooden-framed Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_streaks.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:steel_framed_glass", {
description = "Steel-framed Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_streaks.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:wooden_framed_obsidian_glass", {
description = "Wooden-framed Obsidian Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_clean.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
-- helper functions copied partly from Unified Dyes
local creative_mode = minetest.setting_getbool("creative_mode")
local function select_node(pointed_thing)
local pos = pointed_thing.under
local node = minetest.get_node_or_nil(pos)
local def = node and minetest.registered_nodes[node.name]
if not def or not def.buildable_to then
pos = pointed_thing.above
node = minetest.get_node_or_nil(pos)
def = node and minetest.registered_nodes[node.name]
end
return def and pos, def
end
local function is_buildable_to(placer_name, ...)
for _, pos in ipairs({...}) do
local node = minetest.get_node_or_nil(pos)
local def = node and minetest.registered_nodes[node.name]
if not (def and def.buildable_to) or minetest.is_protected(pos, placer_name) then
return false
end
end
return true
end
local color_on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local itemname = itemstack:get_name()
if not string.find(itemname, "dye:") then
if minetest.registered_nodes[node.name] then
local pos2 = select_node(pointed_thing)
if pos2 and is_buildable_to(clicker, pos2) then
minetest.set_node(pos2, { name = itemname })
if not creative_mode then
itemstack:take_item()
end
end
end
return itemstack
end
local a,b = string.find(node.name, "_glass")
local oldcolor = string.sub(node.name, b + 1)
local newcolor = string.sub(itemname, string.find(itemname, ":") + 1)
local oldcolor2 = string.gsub(oldcolor, "darkgreen", "dark_green")
local oldcolor2 = string.gsub(oldcolor2, "darkgrey", "dark_grey")
local newcolor2 = string.gsub(newcolor, "dark_green", "darkgreen")
local newcolor2 = string.gsub(newcolor2, "dark_grey", "darkgrey")
if oldcolor == newcolor2 then
minetest.chat_send_player(clicker:get_player_name(), "That node is already "..newcolor.."." )
return itemstack
end
if not (newcolor == "dark_grey"
or newcolor == "dark_green"
or minetest.registered_nodes["framedglass:steel_framed_obsidian_glass"..newcolor]) then
minetest.chat_send_player(clicker:get_player_name(), "Framed glass doesn't support "..newcolor.."." )
return itemstack
end
local inv = clicker:get_inventory()
local prevdye = "dye:"..oldcolor2
print(oldcolor, oldcolor2, newcolor, newcolor2, prevdye)
if not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
if inv:room_for_item("main", prevdye) then
inv:add_item("main", prevdye)
else
minetest.add_item(pos, prevdye)
end
end
minetest.set_node(pos, { name = "framedglass:steel_framed_obsidian_glass"..newcolor2 })
itemstack:take_item()
return itemstack
end
local return_dye_after_dig = function(pos, oldnode, oldmetadata, digger)
local a,b = string.find(oldnode.name, "_glass")
local oldcolor = string.sub(oldnode.name, b + 1)
local oldcolor2 = string.gsub(oldcolor, "darkgreen", "dark_green")
local oldcolor2 = string.gsub(oldcolor2, "darkgrey", "dark_grey")
local prevdye = "dye:"..oldcolor2
local inv = digger:get_inventory()
if prevdye and not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
if inv:room_for_item("main", prevdye) then
inv:add_item("main", prevdye)
else
minetest.add_item(pos, prevdye)
end
end
end
minetest.register_node("framedglass:steel_framed_obsidian_glass", {
description = "Steel-framed Obsidian Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_clean.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
on_rightclick = color_on_rightclick,
after_dig_node = return_dye_after_dig
})
function add_coloured_framedglass(name, desc, color)
minetest.register_node( "framedglass:steel_framed_obsidian_glass"..name, {
description = "Steel-framed "..desc.." Obsidian Glass",
tiles = {
"framedglass_steel_frame.png",
{ name = "framedglass_whiteglass.png", color = color }
},
drawtype = "glasslike_framed",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = true,
use_texture_alpha = true,
groups = {cracky=3, not_in_creative_inventory=1},
sounds = default.node_sound_glass_defaults(),
on_rightclick = color_on_rightclick,
after_dig_node = return_dye_after_dig,
drop = "framedglass:steel_framed_obsidian_glass"
})
end
add_coloured_framedglass ("red", "Red", 0xffff0000)
add_coloured_framedglass ("orange", "Orange", 0xfffe7f00)
add_coloured_framedglass ("yellow", "Yellow", 0xffffff01)
add_coloured_framedglass ("green", "Green", 0xff0cff00)
add_coloured_framedglass ("cyan", "Cyan", 0xff7affff)
add_coloured_framedglass ("blue", "Blue", 0xff1600ff)
add_coloured_framedglass ("violet", "Violet", 0xff7d00ff)
add_coloured_framedglass ("magenta", "Magenta", 0xfffd05ff)
add_coloured_framedglass ("darkgreen", "Dark Green", 0xff144f00)
add_coloured_framedglass ("pink", "Pink", 0xffffa4a4)
add_coloured_framedglass ("brown", "Brown", 0xff542a00)
add_coloured_framedglass ("white", "White", 0xffffffff)
add_coloured_framedglass ("grey", "Grey", 0xff7f817e)
add_coloured_framedglass ("darkgrey", "Dark Grey", 0xff3f403e)
add_coloured_framedglass ("black", "Black", 0xff000000)
|