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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
--Unified Bricks by Vsevolod Borislav (wowiamdiamonds)
--
--License: WTFPL
--
--Depends: default, bucket, unifieddyes, vessels
--
--Obviously, offers the same colors in unifieddyes.
--Thanks go to VanessaE for making unifieddyes, gentextures.sh, etc.
unifiedbricks = {}
unifiedbricks.old_static_list = {}
unifiedbricks.old_static_list_formals = {}
minetest.register_alias("unifieddyes:white","unifieddyes:white_paint")
minetest.register_alias("unifieddyes:lightgrey","unifieddyes:lightgrey_paint")
minetest.register_alias("unifieddyes:grey","unifieddyes:grey_paint")
minetest.register_alias("unifieddyes:darkgrey","unifieddyes:darkgrey_paint")
HUES = {
"red",
"orange",
"yellow",
"lime",
"green",
"aqua",
"cyan",
"skyblue",
"blue",
"violet",
"magenta",
"redviolet",
"black",
"darkgrey",
"grey",
"lightgrey",
"white"
}
TYPES = {
"clayblock_",
"clay_",
"brick_",
"brickblock_",
"multicolor_"
}
SATURATION = {
"_s50",
""
}
DARKNESS = {
"dark_",
"medium_",
"",
"light_"
}
--formal versions
FORMALHUES = {
"Red",
"Orange",
"Yellow",
"Lime",
"Green",
"Aqua",
"Cyan",
"Sky blue",
"Blue",
"Violet",
"Magenta",
"Red violet",
"Black",
"Dark grey",
"Grey",
"Light grey",
"White"
}
FORMALTYPES = {
" clay",
" clay lump",
" brick",
" bricks",
" multicolor bricks"
}
FORMALSATURATION = {
" (low saturation)",
""
}
FORMALDARKNESS = {
"Dark ",
"Medium ",
"Bright ",
"Light "
}
-- param2-coloring-enabled nodes
minetest.register_node("unifiedbricks:brickblock", {
description = "Brick Block",
tiles = {
"unifiedbricks_brickblock.png"
},
overlay_tiles = {
{ name = "unifiedbricks_mortar.png", color = "white" }
},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
place_param2 = 240,
is_ground_content = true,
groups = {cracky=3, not_in_creative_inventory=1, ud_param2_colorable = 1},
sounds = default.node_sound_stone_defaults(),
on_construct = unifieddyes.on_construct,
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
drop = "default:brick"
})
minetest.override_item("default:brick", {
ud_replacement_node = "unifiedbricks:brickblock",
palette = "unifieddyes_palette_extended.png",
groups = {cracky = 3, ud_param2_colorable = 1},
after_place_node = unifieddyes.recolor_on_place
})
minetest.register_node("unifiedbricks:clayblock", {
description = "Clay Block",
tiles = {
"unifiedbricks_clayblock.png",
},
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
place_param2 = 240,
is_ground_content = true,
groups = {crumbly=3, not_in_creative_inventory=1, ud_param2_colorable = 1},
sounds = default.node_sound_dirt_defaults({
footstep = "",
}),
on_construct = unifieddyes.on_construct,
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
drop = "default:clay"
})
minetest.override_item("default:clay", {
ud_replacement_node = "unifiedbricks:clayblock",
palette = "unifieddyes_palette_extended.png",
groups = {crumbly = 3, ud_param2_colorable = 1},
after_place_node = unifieddyes.recolor_on_place,
})
minetest.register_node("unifiedbricks:brickblock_multicolor_dark", {
description = "Brick block (dark multicolor)",
tiles = {
"unifiedbricks_brickblock_multicolor_dark.png",
},
overlay_tiles = {
{ name = "unifiedbricks_mortar2.png", color = "white" }
},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
place_param2 = 240,
is_ground_content = true,
groups = {cracky=3, ud_param2_colorable = 1},
sounds = default.node_sound_stone_defaults(),
on_construct = unifieddyes.on_construct,
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
})
minetest.register_node("unifiedbricks:brickblock_multicolor_medium", {
description = "Brick block (medium multicolor)",
tiles = {
"unifiedbricks_brickblock_multicolor_medium.png"
},
overlay_tiles = {
{ name = "unifiedbricks_mortar3.png", color = "white" }
},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
place_param2 = 240,
is_ground_content = true,
groups = {cracky=3, ud_param2_colorable = 1},
sounds = default.node_sound_stone_defaults(),
on_construct = unifieddyes.on_construct,
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
})
minetest.register_node("unifiedbricks:brickblock_multicolor_light", {
description = "Brick block (light multicolor)",
tiles = {
"unifiedbricks_brickblock_multicolor_light.png"
},
overlay_tiles = {
{ name = "unifiedbricks_mortar4.png", color = "white" }
},
use_texture_alpha = true,
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
place_param2 = 240,
is_ground_content = true,
groups = {cracky=3, ud_param2_colorable = 1},
sounds = default.node_sound_stone_defaults(),
on_construct = unifieddyes.on_construct,
after_place_node = unifieddyes.recolor_on_place,
after_dig_node = unifieddyes.after_dig_node,
})
minetest.register_craft( {
type = "shapeless",
output = "unifiedbricks:brickblock_multicolor_dark",
recipe = {
"default:brick",
"unifieddyes:grey",
"unifieddyes:dark_grey",
"unifieddyes:dark_grey"
},
})
minetest.register_craft( {
type = "shapeless",
output = "unifiedbricks:brickblock_multicolor_medium",
recipe = {
"default:brick",
"unifieddyes:white",
"unifieddyes:grey",
"unifieddyes:dark_grey"
},
})
minetest.register_craft( {
type = "shapeless",
output = "unifiedbricks:brickblock_multicolor_light",
recipe = {
"default:brick",
"unifieddyes:white",
"unifieddyes:white",
"unifieddyes:grey"
},
})
-- static nodes
unifiedbricks.register_old_static_block = function(name, formalname, blocktype)
table.insert(unifiedbricks.old_static_list, "unifiedbricks:"..blocktype.."_"..name)
table.insert(unifiedbricks.old_static_list_formals, formalname)
end
for _, color in ipairs(HUES) do
table.insert(unifiedbricks.old_static_list, "unifiedbricks:multicolor_dark_"..color)
table.insert(unifiedbricks.old_static_list, "unifiedbricks:multicolor_medium_"..color)
table.insert(unifiedbricks.old_static_list, "unifiedbricks:multicolor_light_"..color)
end
table.insert(unifiedbricks.old_static_list, "unifiedbricks:multicolor_darkgrey")
table.insert(unifiedbricks.old_static_list, "unifiedbricks:multicolor_grey")
table.insert(unifiedbricks.old_static_list, "unifiedbricks:multicolor_lightgrey")
--REGISTERS ALL STATIC NODES EXCEPT MULTICOLOR BRICK BLOCKS
for i = 1,17 do
for j = 1,4 do
if i > 12 then
formalname = FORMALHUES[i]
name = HUES[i]
if j == 1 then
unifiedbricks.register_old_static_block(name, formalname, "clayblock")
elseif j == 4 then
unifiedbricks.register_old_static_block(name, formalname, "brickblock")
end
else
for k = 1,4 do
if k == 4 then
formalname = FORMALDARKNESS[k] .. FORMALHUES[i]
name = DARKNESS[k] .. HUES[i]
if j == 1 then
unifiedbricks.register_old_static_block(name, formalname, "clayblock")
elseif j == 4 then
unifiedbricks.register_old_static_block(name, formalname, "brickblock")
end
else
for l = 1,2 do
formalname = FORMALDARKNESS[k] .. FORMALHUES[i] .. FORMALSATURATION[l]
name = DARKNESS[k] .. HUES[i] .. SATURATION[l]
if j == 1 then
unifiedbricks.register_old_static_block(name, formalname, "clayblock")
elseif j == 4 then
unifiedbricks.register_old_static_block(name, formalname, "brickblock")
end
end
end
end
end
end
end
-- convert in-map static nodes to use param2 coloring
minetest.register_lbm({
name = "unifiedbricks:convert_brickblocks",
label = "Convert clay blocks and single-color brick blocks to use param2 color",
run_at_every_load = false,
nodenames = unifiedbricks.old_static_list,
action = function(pos, node)
local name = node.name
local t = string.find(name, "_")
local type = string.sub(name, 1, t - 1)
local color1 = string.sub(name, t + 1)
local color2 = string.gsub(color1, "grey", "_grey")
if color2 == "_grey" then color2 = "grey" end
local paletteidx, hue = unifieddyes.getpaletteidx("unifieddyes:"..color2, "extended")
if string.find(type, "multicolor") then
local newpalette = (hue*8)+1
local shade
if string.find(name, "dark") then
shade = "dark"
elseif string.find(name, "medium")
or name == "unifiedbricks:multicolor_grey" then
shade = "medium"
else
shade = "light"
end
if string.find(name, "grey") then
newpalette = 2
end
minetest.set_node(pos, { name = "unifiedbricks:brickblock_multicolor_"..shade, param2 = newpalette })
elseif string.find(type, "brickblock") then
minetest.set_node(pos, { name = "unifiedbricks:brickblock", param2 = paletteidx })
elseif string.find(type, "clayblock") then
minetest.set_node(pos, { name = "unifiedbricks:clayblock", param2 = paletteidx })
end
local meta = minetest.get_meta(pos)
meta:set_string("dye", "unifieddyes:"..color1)
meta:set_string("palette", "ext")
end
})
minetest.register_lbm({
name = "unifiedbricks:recolor_bricks",
label = "Convert 89-color bricks to use UD extended palette",
run_at_every_load = false,
nodenames = {
"unifiedbricks:clayblock",
"unifiedbricks:brickblock",
"unifiedbricks:brickblock_multicolor_dark",
"unifiedbricks:brickblock_multicolor_medium",
"unifiedbricks:brickblock_multicolor_light",
},
action = function(pos, node)
local meta = minetest.get_meta(pos)
if meta:get_string("palette") ~= "ext" then
minetest.swap_node(pos, { name = node.name, param2 = unifieddyes.convert_classic_palette[node.param2] })
meta:set_string("palette", "ext")
end
end
})
print("[UnifiedBricks] Loaded!")
|