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
|
-- [Mod] Simple Arcs [pkarcs]
-- by PEAK
-- 06-05-2017
--[[
This mod adds arc-nodes to Minetest as well as arcs for inner and outer
corners, based on the default stone and wood materials.
To make arcs from nodes of your mod, put "pkarcs?" into your depends.txt,
and call this function in your init.lua:
if minetest.get_modpath("pkarcs") then
pkarcs.register_node("your_mod:your_nodename")
end
works with Minetest 0.4.16
--]]
pkarcs = {}
-- convert integer coordinates to nodebox coordinates
function nb(n)
return n/16-1/2
end
-- define nodes
function pkarcs.register_all(nodename, desc, tile, sound, group, craftmaterial)
local tile_collection
if type(tile) == "string" then
tile_collection[1] = tile
else
tile_collection = table.copy(tile)
end
minetest.register_node(":pkarcs:"..nodename.."_arc", {
description = desc.." Arc",
paramtype = "light",
paramtype2 = "facedir",
tiles = tile_collection,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ nb(0), nb(0), nb(0), nb(1), nb(16), nb(16) },
{ nb(1), nb(4), nb(0), nb(2), nb(16), nb(16) },
{ nb(2), nb(7), nb(0), nb(3), nb(16), nb(16) },
{ nb(3), nb(8), nb(0), nb(4), nb(16), nb(16) },
{ nb(4), nb(10), nb(0), nb(5), nb(16), nb(16) },
{ nb(5), nb(11), nb(0), nb(6), nb(16), nb(16) },
{ nb(6), nb(12), nb(0), nb(8), nb(16), nb(16) },
{ nb(8), nb(13), nb(0), nb(9), nb(16), nb(16) },
{ nb(9), nb(14), nb(0), nb(12), nb(16), nb(16) },
{ nb(12), nb(15), nb(0), nb(16), nb(16), nb(16) },
}
},
groups = group,
sounds = sound,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p1 = pointed_thing.under
local p0 = pointed_thing.above
local param2 = 0
local placer_pos = placer:getpos()
if placer_pos then
local dir = {
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y-1 == p1.y then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
local NROT = 4 -- Number of possible "rotations" (4 Up down left right)
local rot = param2 % NROT
local wall = math.floor(param2/NROT)
if rot >=3 then
rot = 0
else
rot = rot +1
end
param2 = wall*NROT+rot
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
})
minetest.register_craft({
output = "pkarcs:"..nodename.."_arc".." 5",
recipe = {
{ craftmaterial, craftmaterial, craftmaterial },
{ craftmaterial, "", "" },
{ craftmaterial, "", "" }
}
})
minetest.register_node(":pkarcs:"..nodename.."_outer_arc", {
description = desc.." Outer Arc",
paramtype = "light",
paramtype2 = "facedir",
tiles = tile_collection,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ nb(0), nb(0), nb(16), nb(1), nb(16), nb(16-1) },
{ nb(0), nb(4), nb(16), nb(2), nb(16), nb(16-2) },
{ nb(0), nb(7), nb(16), nb(3), nb(16), nb(16-3) },
{ nb(0), nb(8), nb(16), nb(4), nb(16), nb(16-4) },
{ nb(0), nb(10), nb(16), nb(5), nb(16), nb(16-5) },
{ nb(0), nb(11), nb(16), nb(6), nb(16), nb(16-6) },
{ nb(0), nb(12), nb(16), nb(8), nb(16), nb(16-8) },
{ nb(0), nb(13), nb(16), nb(9), nb(16), nb(16-9) },
{ nb(0), nb(14), nb(16), nb(12), nb(16), nb(16-12) },
{ nb(0), nb(15), nb(16), nb(16), nb(16), nb(16-16) },
}
},
groups = group,
sounds = sound,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p1 = pointed_thing.under
local p0 = pointed_thing.above
local param2 = 0
local placer_pos = placer:getpos()
if placer_pos then
local dir = {
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y-1 == p1.y then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
local NROT = 4 -- Number of possible "rotations" (4 Up down left right)
local rot = param2 % NROT
local wall = math.floor(param2/NROT)
if rot >=3 then
rot = 0
else
rot = rot +1
end
param2 = wall*NROT+rot
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
})
minetest.register_craft({
output = "pkarcs:"..nodename.."_outer_arc".." 5",
recipe = {
{ "default:torch", craftmaterial, craftmaterial },
{ craftmaterial, "", "" },
{ craftmaterial, "", "" }
}
})
minetest.register_node(":pkarcs:"..nodename.."_inner_arc", {
description = desc.." Inner Arc",
paramtype = "light",
paramtype2 = "facedir",
tiles = tile_collection,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ nb(0), nb(0), nb(16), nb(1), nb(16), nb(0) },
{ nb(0), nb(0), nb(16), nb(16), nb(16), nb(16-1) },
{ nb(0), nb(4), nb(16), nb(2), nb(16), nb(0) },
{ nb(0), nb(4), nb(16), nb(16), nb(16), nb(16-2) },
{ nb(0), nb(7), nb(16), nb(3), nb(16), nb(0) },
{ nb(0), nb(7), nb(16), nb(16), nb(16), nb(16-3) },
{ nb(0), nb(8), nb(16), nb(4), nb(16), nb(0) },
{ nb(0), nb(8), nb(16), nb(16), nb(16), nb(16-4) },
{ nb(0), nb(10), nb(16), nb(5), nb(16), nb(0) },
{ nb(0), nb(10), nb(16), nb(16), nb(16), nb(16-5) },
{ nb(0), nb(11), nb(16), nb(6), nb(16), nb(0) },
{ nb(0), nb(11), nb(16), nb(16), nb(16), nb(16-6) },
{ nb(0), nb(12), nb(16), nb(8), nb(16), nb(0) },
{ nb(0), nb(12), nb(16), nb(16), nb(16), nb(16-8) },
{ nb(0), nb(13), nb(16), nb(9), nb(16), nb(0) },
{ nb(0), nb(13), nb(16), nb(16), nb(16), nb(16-9) },
{ nb(0), nb(14), nb(16), nb(12), nb(16), nb(0) },
{ nb(0), nb(14), nb(16), nb(16), nb(16), nb(16-12) },
{ nb(0), nb(15), nb(16), nb(16), nb(16), nb(16-16) },
}
},
groups = group,
sounds = sound,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p1 = pointed_thing.under
local p0 = pointed_thing.above
local param2 = 0
local placer_pos = placer:getpos()
if placer_pos then
local dir = {
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y-1 == p1.y then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
local NROT = 4 -- Number of possible "rotations" (4 Up down left right)
local rot = param2 % NROT
local wall = math.floor(param2/NROT)
if rot >=3 then
rot = 0
else
rot = rot +1
end
param2 = wall*NROT+rot
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
})
minetest.register_craft({
output = "pkarcs:"..nodename.."_inner_arc".." 5",
recipe = {
{ "", craftmaterial, craftmaterial },
{ craftmaterial, "default:torch", "" },
{ craftmaterial, "", "" }
}
})
end
-- register nodes
function pkarcs.register_node(name)
local node_def = minetest.registered_nodes[name]
if not node_def then
minetest.log("warning", "[pkarcs] Skipping unknown node: ".. name)
return
end
local node_name = name:split(':')[2]
if not node_def.tiles then
node_def.tiles = table.copy(node_def.tile_images)
node_def.tile_images = nil
end
pkarcs.register_all(node_name, node_def.description, node_def.tiles, node_def.sound, node_def.groups, name)
end
-- make arcs for all default stone and wood nodes
pkarcs.register_node("default:cobble")
pkarcs.register_node("default:mossycobble")
pkarcs.register_node("default:desert_cobble")
pkarcs.register_node("default:stone")
pkarcs.register_node("default:stonebrick")
pkarcs.register_node("default:stone_block")
pkarcs.register_node("default:desert_stone")
pkarcs.register_node("default:desert_stonebrick")
pkarcs.register_node("default:desert_stone_block")
pkarcs.register_node("default:desert_sandstone")
pkarcs.register_node("default:desert_sandstone_block")
pkarcs.register_node("default:desert_sandstone_brick")
pkarcs.register_node("default:silver_sandstone")
pkarcs.register_node("default:silver_sandstone_block")
pkarcs.register_node("default:silver_sandstone_brick")
pkarcs.register_node("default:sandstone")
pkarcs.register_node("default:sandstonebrick")
pkarcs.register_node("default:sandstone_block")
pkarcs.register_node("default:brick")
pkarcs.register_node("default:obsidian")
pkarcs.register_node("default:obsidianbrick")
pkarcs.register_node("default:obsidian_block")
pkarcs.register_node("default:wood")
pkarcs.register_node("default:junglewood")
pkarcs.register_node("default:pine_wood")
pkarcs.register_node("default:acacia_wood")
pkarcs.register_node("default:aspen_wood")
-- mod-specific materials
if minetest.get_modpath("ethereal") then
pkarcs.register_node("ethereal:banana_wood")
pkarcs.register_node("ethereal:birch_wood")
pkarcs.register_node("ethereal:frost_wood")
pkarcs.register_node("ethereal:palm_wood")
pkarcs.register_node("ethereal:willow_wood")
pkarcs.register_node("ethereal:yellow_wood")
pkarcs.register_node("ethereal:redwood_wood")
pkarcs.register_node("ethereal:bamboo_floor")
end
if minetest.get_modpath("bakedclay") then
local clay = {"white", "grey", "black", "red", "yellow",
"green", "cyan", "blue", "magenta", "orange",
"violet", "brown", "pink", "dark_grey", "dark_green"}
for _,c in ipairs(clay) do
pkarcs.register_node("bakedclay:" .. c)
end
end
|