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
|
-- BobBlocks mod by RabbiBob
-- State Changes
bobblocks = {}
bobblocks.old_static_nodes = {}
bobblocks.colorlist = {
"red",
"orange",
"yellow",
"green",
"blue",
"indigo",
"violet",
"white",
"grey"
}
bobblocks.update_bobblock = function (pos, node)
local newnode = node
if string.find(newnode.name, "_off") then
newnode.name = string.sub(newnode.name, 1, -5)
else
newnode.name = newnode.name.."_off"
end
minetest.swap_node(pos, newnode)
minetest.sound_play("bobblocks_glassblock",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
end
-- Nodes
minetest.register_node("bobblocks:block", {
description = "Bobblocks Plain Block",
drawtype = "glasslike",
tiles = {"bobblocks_block.png"},
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette.png",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_glass_defaults(),
light_source = LIGHT_MAX-0,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, ud_param2_colorable = 1},
foo = {conductor={
state = mesecon.state.on,
offstate = "bobblocks:block_off"
}
},
on_punch = bobblocks.update_bobblock,
after_dig_node = unifieddyes.after_dig_node
})
minetest.register_node("bobblocks:block_off", {
description = "Bobblocks Plain Block (off)",
tiles = {"bobblocks_block.png"},
paramtype2 = "color",
palette = "unifieddyes_palette.png",
is_ground_content = true,
alpha = WATER_ALPHA,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1, ud_param2_colorable = 1},
drop = 'bobblocks:redblock',
foo = {conductor={
state = mesecon.state.off,
onstate = "bobblocks:block"
}
},
on_rightclick = bobblocks.update_bobblock,
after_dig_node = unifieddyes.after_dig_node
})
-- Block Poles
minetest.register_node("bobblocks:pole", {
description = "Bobblocks Pole",
drawtype = "fencelike",
tiles = {"bobblocks_block.png"},
inventory_image = ("bobblocks_pole_inv.png"),
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette.png",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_glass_defaults(),
light_source = LIGHT_MAX-0,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, ud_param2_colorable = 1},
foo = {conductor={
state = mesecon.state.on,
offstate = "bobblocks:pole_off"
}
},
on_rightclick = bobblocks.update_bobblock,
after_dig_node = unifieddyes.after_dig_node
})
minetest.register_node("bobblocks:pole_off", {
description = "Bobblocks Pole (off)",
drawtype = "fencelike",
tiles = {"bobblocks_block.png"},
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette.png",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_glass_defaults(),
light_source = LIGHT_MAX-10,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1, ud_param2_colorable = 1},
drop = 'bobblocks:redpole',
foo = {conductor={
state = mesecon.state.off,
onstate = "bobblocks:pole"
}
},
on_rightclick = bobblocks.update_bobblock,
after_dig_node = unifieddyes.after_dig_node
})
-- old static nodes grandfathered-in because they have a different texture or usage than the colored ones.
minetest.register_node("bobblocks:btm", {
description = "Bobs TransMorgifier v5",
tiles = {"bobblocks_btm_sides.png", "bobblocks_btm_sides.png", "bobblocks_btm_sides.png",
"bobblocks_btm_sides.png", "bobblocks_btm_sides.png", "bobblocks_btm.png"},
inventory_image = "bobblocks_btm.png",
paramtype2 = "facedir",
material = minetest.digprop_dirtlike(1.0),
legacy_facedir_simple = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
})
minetest.register_node("bobblocks:wavyblock", {
description = "Bobblocks Wavy-textured Block",
drawtype = "glasslike",
tiles = {"bobblocks_wavyblock.png"},
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette.png",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_glass_defaults(),
light_source = LIGHT_MAX-0,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, ud_param2_colorable = 1},
foo = {conductor=
{
state = mesecon.state.on,
offstate = "bobblocks:wavyblock_off"
}
},
after_dig_node = unifieddyes.after_dig_node
})
minetest.register_node("bobblocks:wavyblock_off", {
description = "Bobblocks Wavy-textured Block (off)",
tiles = {"bobblocks_wavyblock.png"},
paramtype2 = "color",
palette = "unifieddyes_palette.png",
is_ground_content = true,
alpha = WATER_ALPHA,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1, ud_param2_colorable = 1},
drop = 'bobblocks:wavyblock',
foo = {conductor=
{
state = mesecon.state.off,
onstate = "bobblocks:wavyblock"
}
},
after_dig_node = unifieddyes.after_dig_node
})
minetest.register_node("bobblocks:wavypole", {
description = "Wavy-textured Pole",
drawtype = "fencelike",
tiles = {"bobblocks_wavyblock.png"},
inventory_image = ("bobblocks_wavypole_inv.png"),
paramtype = "light",
paramtype2 = "color",
palette = "unifieddyes_palette.png",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_glass_defaults(),
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, ud_param2_colorable = 1},
after_dig_node = unifieddyes.after_dig_node,
--light_source = LIGHT_MAX-0,
})
-- Crafts
minetest.register_craft({
output = "bobblocks:btm",
type = "shapeless",
recipe = {
"default:glass",
"default:torch",
"group:leaves",
"default:mese_crystal",
"default:diamond"
},
})
minetest.register_craft({
output = "bobblocks:block 2",
recipe = {
{ "default:glass", "default:torch", "default:cobble" },
},
})
minetest.register_craft({
output = "bobblocks:pole",
recipe = {
{ "bobblocks:block", "group:stick" },
}
})
minetest.register_craft({
output = "bobblocks:wavyblock 2",
type = "shapeless",
recipe = {
"bobblocks:block",
"bobblocks:block"
},
})
minetest.register_craft({
output = "bobblocks:wavypole",
recipe = {
{ "bobblocks:wavyblock", "group:stick" },
}
})
-- Convert old static nodes to the param2 scheme
for _, i in ipairs(bobblocks.colorlist) do
table.insert(bobblocks.old_static_nodes, "bobblocks:"..i.."block")
table.insert(bobblocks.old_static_nodes, "bobblocks:"..i.."block_off")
table.insert(bobblocks.old_static_nodes, "bobblocks:"..i.."pole")
table.insert(bobblocks.old_static_nodes, "bobblocks:"..i.."pole_off")
end
minetest.register_lbm({
name = "bobblocks:convert",
label = "Convert bobblocks nodes to use param2 color",
run_at_every_load = false,
nodenames = bobblocks.old_static_nodes,
action = function(pos, node)
local basename = node.name
local color = string.sub(node.name, 11) -- delete the mod name
if string.find(color, "_off") then -- delete "_off" if it exists
color = string.sub(color, 1, -5)
end
if string.find(color, "pole") then
color = string.sub(color, 1, -5) -- delete "pole"...
else
color = string.sub(color, 1, -6) -- or delete "block"
end
local newcolor = "medium_"..color -- the result of the above should be just the hue
-- custom re-mappings to use unified dyes' colors that are most similar to the originals
if color == "blue" then
newcolor = "medium_skyblue"
end
if color == "indigo" then
newcolor = "light_violet"
end
if color == "violet" then
newcolor = "violet_s50"
end
if color == "white" then
newcolor = "light_grey"
end
local paletteidx, _ = unifieddyes.getpaletteidx("unifieddyes:"..newcolor, false)
local newnode = "bobblocks:block"
if string.find(basename, "grey") then
paletteidx, _ = unifieddyes.getpaletteidx("unifieddyes:grey", false)
if string.find(basename, "pole") then
newnode = "bobblocks:wavypole"
else
newnode = "bobblocks:wavyblock"
end
else
if string.find(basename, "pole") then
newnode = "bobblocks:pole"
end
end
local meta = minetest.get_meta(pos)
minetest.set_node(pos, { name = newnode, param2 = paletteidx })
meta:set_string("dye", "unifieddyes:"..newcolor)
end
})
|