Rename mod: walls → hades_walls
[minetest_hades/hades_revisited.git] / mods / columnia / columnia.lua
blob6b0a4519b349c4b0008140d933d15e55fefc7186
1 local S = minetest.get_translator("columnia")
3 columnia.registered_materials = {}
5 function columnia.register_all(craft, desc, image, groups, sounds, mat)
7 if not mat then
8 mat = string.gsub(craft, ":", "_")
9 end
11 if not desc then
12 desc = minetest.registered_items[craft].description
13 end
15 if not image then
16 image = minetest.registered_items[craft].tiles[1]
17 end
19 if not groups then
20 groups = table.copy(minetest.registered_items[craft].groups)
21 end
22 groups.not_in_creative_inventory = 1
23 groups.wood = nil
24 groups.cloth = nil
25 groups.stone = nil
26 groups.claybricks = nil
27 groups.colwood = nil
29 if not sounds then
30 sounds = minetest.registered_items[craft].sounds
31 end
33 local on_place = function(itemstack, placer, pointed_thing)
34 if pointed_thing.type ~= "node" then
35 return itemstack
36 end
38 local p0 = pointed_thing.under
39 local p1 = pointed_thing.above
40 local param2 = 0
42 local placer_pos = placer:get_pos()
43 if placer_pos then
44 local dir = {
45 x = p1.x - placer_pos.x,
46 y = p1.y - placer_pos.y,
47 z = p1.z - placer_pos.z
49 param2 = minetest.dir_to_facedir(dir)
50 end
52 if p0.y-1 == p1.y then
53 param2 = param2 + 20
54 if param2 == 21 then
55 param2 = 23
56 elseif param2 == 23 then
57 param2 = 21
58 end
59 end
61 return minetest.item_place(itemstack, placer, pointed_thing, param2)
62 end
64 columnia.registered_materials[craft] = mat
66 -- Make it a world-aligned tile if align_style is not set
67 local tile
68 if type(image) == "table" then
69 tile = table.copy(image)
70 if tile.align_style == nil then
71 tile.align_style = "world"
72 end
73 else
74 tile = { name = image, align_style = "world" }
75 end
76 local tiles = {tile}
78 minetest.register_node("columnia:column_mid_"..mat, {
79 description = S("@1 Column", desc),
80 drawtype = "nodebox",
81 tiles = tiles,
82 paramtype = "light",
83 paramtype2 = "facedir",
84 sunlight_propagates = true,
85 is_ground_content = false,
86 groups = groups,
87 node_box = {
88 type = "fixed",
89 fixed = {
90 {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25},
93 on_place = on_place,
94 on_rotate = "simple",
95 sounds = sounds,
96 _hades_shaper_next = "columnia:column_top_"..mat,
99 local mod_screwdriver = minetest.get_modpath("screwdriver")
100 local on_rotate_column_top, on_rotate_column_bottom
101 if mod_screwdriver then
102 on_rotate_column_top = function(pos, node, user, mode, new_param2)
103 if mode == screwdriver.ROTATE_AXIS then
104 node.name = "columnia:column_bottom_"..mat
105 minetest.swap_node(pos, node)
106 return false
109 on_rotate_column_bottom = function(pos, node, user, mode, new_param2)
110 if mode == screwdriver.ROTATE_AXIS then
111 node.name = "columnia:column_top_"..mat
112 minetest.swap_node(pos, node)
113 return false
118 minetest.register_node("columnia:column_top_"..mat, {
119 description = S("@1 Column Top", desc),
120 drawtype = "nodebox",
121 tiles = tiles,
122 paramtype = "light",
123 paramtype2 = "facedir",
124 sunlight_propagates = true,
125 is_ground_content = false,
126 groups = groups,
127 node_box = {
128 type = "fixed",
129 fixed = {
130 {-0.25, -0.5, -0.25, 0.25, 0, 0.25},
131 {-0.375, 0, -0.375, 0.375, 0.25, 0.375},
132 {-0.5, 0.25, -0.5, 0.5, 0.5, 0.5},
135 on_place = on_place,
136 on_rotate = on_rotate_column_top,
137 sounds = sounds,
138 _hades_shaper_next = "columnia:column_bottom_"..mat,
141 minetest.register_node("columnia:column_bottom_"..mat, {
142 description = S("@1 Column Bottom", desc),
143 drawtype = "nodebox",
144 tiles = tiles,
145 paramtype = "light",
146 paramtype2 = "facedir",
147 sunlight_propagates = true,
148 is_ground_content = false,
149 groups = groups,
150 node_box = {
151 type = "fixed",
152 fixed = {
153 {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
154 {-0.375, -0.25, -0.375, 0.375, 0, 0.375},
155 {-0.25, 0, -0.25, 0.25, 0.5, 0.25},
158 on_place = on_place,
159 on_rotate = on_rotate_column_bottom,
160 sounds = sounds,
161 _hades_shaper_next = "columnia:column_mid_"..mat,
164 minetest.register_node("columnia:column_crosslink_"..mat, {
165 description = S("@1 Column Crosslink", desc),
166 drawtype = "nodebox",
167 tiles = tiles,
168 paramtype = "light",
169 paramtype2 = "facedir",
170 sunlight_propagates = true,
171 is_ground_content = false,
172 groups = groups,
173 node_box = {
174 type = "fixed",
175 fixed = {
176 {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25},
177 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
178 {-0.25, 0, -0.5, 0.25, 0.5, 0.5},
179 {-0.4375, 0.0625, -0.4375, 0.4375, 0.4375, 0.4375},
182 on_place = on_place,
183 on_rotate = "simple",
184 sounds = sounds,
187 minetest.register_node("columnia:column_link_"..mat, {
188 description = S("@1 Column Link", desc),
189 drawtype = "nodebox",
190 tiles = tiles,
191 paramtype = "light",
192 paramtype2 = "facedir",
193 sunlight_propagates = true,
194 is_ground_content = false,
195 groups = groups,
196 node_box = {
197 type = "fixed",
198 fixed = {
199 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
202 on_place = on_place,
203 on_rotate = "simple",
204 sounds = sounds,
205 _hades_shaper_next = "columnia:column_linktee_"..mat,
208 minetest.register_node("columnia:column_linkdown_"..mat, {
209 description = S("@1 Column Link Down", desc),
210 drawtype = "nodebox",
211 tiles = tiles,
212 paramtype = "light",
213 paramtype2 = "facedir",
214 sunlight_propagates = true,
215 is_ground_content = false,
216 groups = groups,
217 node_box = {
218 type = "fixed",
219 fixed = {
220 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
221 {-0.125, -0.5, -0.125, 0.125, 0, 0.125},
222 {-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
223 {-0.1875, -0.125, -0.1875, 0.1875, 0, 0.1875},
226 on_place = on_place,
227 on_rotate = "simple",
228 sounds = sounds,
229 _hades_shaper_next = "columnia:column_linktee_down_"..mat,
232 minetest.register_node("columnia:column_linkcross_"..mat, {
233 description = S("@1 Column Link Cross", desc),
234 drawtype = "nodebox",
235 tiles = tiles,
236 paramtype = "light",
237 paramtype2 = "facedir",
238 sunlight_propagates = true,
239 is_ground_content = false,
240 groups = groups,
241 node_box = {
242 type = "fixed",
243 fixed = {
244 {-0.25, 0, -0.5, 0.25, 0.5, 0.5},
245 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
248 on_place = on_place,
249 on_rotate = "simple",
250 sounds = sounds,
251 _hades_shaper_next = "columnia:column_linkangle_"..mat,
254 minetest.register_node("columnia:column_linkcrossdown_"..mat, {
255 description = S("@1 Column Link Cross Down", desc),
256 drawtype = "nodebox",
257 tiles = tiles,
258 paramtype = "light",
259 paramtype2 = "facedir",
260 sunlight_propagates = true,
261 is_ground_content = false,
262 groups = groups,
263 node_box = {
264 type = "fixed",
265 fixed = {
266 {-0.25, 0, -0.5, 0.25, 0.5, 0.5},
267 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
268 {-0.1875, -0.125, -0.1875, 0.1875, 0, 0.1875},
269 {-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
270 {-0.125, -0.375, -0.125, 0.125, -0.125, 0.125},
273 on_place = on_place,
274 on_rotate = "simple",
275 sounds = sounds,
276 _hades_shaper_next = "columnia:column_linkangle_down_"..mat,
279 minetest.register_node("columnia:column_linkvertical_"..mat, {
280 description = S("@1 Column Link Vertical", desc),
281 drawtype = "nodebox",
282 tiles = tiles,
283 paramtype = "light",
284 paramtype2 = "facedir",
285 sunlight_propagates = true,
286 is_ground_content = false,
287 groups = groups,
288 node_box = {
289 type = "fixed",
290 fixed = {
291 {-0.1875, 0.375, -0.1875, 0.1875, 0.5, 0.1875},
292 {-0.125, -0.375, -0.125, 0.125, -0.125, 0.125},
293 {-0.1875, -0.125, -0.1875, 0.1875, 0.125, 0.1875},
294 {-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
295 {-0.125, 0.125, -0.125, 0.125, 0.375, 0.125},
298 on_place = on_place,
299 on_rotate = "simple",
300 sounds = sounds,
303 minetest.register_node("columnia:column_linkangle_"..mat, {
304 description = S("@1 Column Link Corner", desc),
305 drawtype = "nodebox",
306 tiles = tiles,
307 paramtype = "light",
308 paramtype2 = "facedir",
309 sunlight_propagates = true,
310 is_ground_content = false,
311 groups = groups,
312 node_box = {
313 type = "fixed",
314 fixed = {
315 {-0.25, 0, -0.25, 0.5, 0.5, 0.25},
316 {-0.25, 0, -0.5, 0.25, 0.5, -0.25},
319 on_place = on_place,
320 on_rotate = "simple",
321 sounds = sounds,
322 _hades_shaper_next = "columnia:column_link_"..mat,
325 minetest.register_node("columnia:column_linkangle_down_"..mat, {
326 description = S("@1 Column Link Corner Down", desc),
327 drawtype = "nodebox",
328 tiles = tiles,
329 paramtype = "light",
330 paramtype2 = "facedir",
331 sunlight_propagates = true,
332 is_ground_content = false,
333 groups = groups,
334 node_box = {
335 type = "fixed",
336 fixed = {
337 {-0.25, 0, -0.25, 0.5, 0.5, 0.25},
338 {-0.25, 0, -0.5, 0.25, 0.5, -0.25},
339 {-0.1875, -0.125, -0.1875, 0.1875, 0, 0.1875},
340 {-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
341 {-0.125, -0.375, -0.125, 0.125, -0.125, 0.125},
344 on_place = on_place,
345 on_rotate = "simple",
346 sounds = sounds,
347 _hades_shaper_next = "columnia:column_linkdown_"..mat,
350 minetest.register_node("columnia:column_linktee_"..mat, {
351 description = S("@1 Column Link T-Form", desc),
352 drawtype = "nodebox",
353 tiles = tiles,
354 paramtype = "light",
355 paramtype2 = "facedir",
356 sunlight_propagates = true,
357 is_ground_content = false,
358 groups = groups,
359 node_box = {
360 type = "fixed",
361 fixed = {
362 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
363 {-0.25, 0, -0.5, 0.25, 0.5, -0.25},
366 on_place = on_place,
367 on_rotate = "simple",
368 sounds = sounds,
369 _hades_shaper_next = "columnia:column_linkcross_"..mat,
372 minetest.register_node("columnia:column_linktee_down_"..mat, {
373 description = S("@1 Column Link T-Form Down", desc),
374 drawtype = "nodebox",
375 tiles = tiles,
376 paramtype = "light",
377 paramtype2 = "facedir",
378 sunlight_propagates = true,
379 is_ground_content = false,
380 groups = groups,
381 node_box = {
382 type = "fixed",
383 fixed = {
384 {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
385 {-0.25, 0, -0.5, 0.25, 0.5, -0.25},
386 {-0.1875, -0.125, -0.1875, 0.1875, 0, 0.1875},
387 {-0.1875, -0.5, -0.1875, 0.1875, -0.375, 0.1875},
388 {-0.125, -0.375, -0.125, 0.125, -0.125, 0.125},
391 on_place = on_place,
392 on_rotate = "simple",
393 sounds = sounds,
394 _hades_shaper_next = "columnia:column_linkcrossdown_"..mat,
397 minetest.register_node("columnia:column_stairsub_"..mat, {
398 description = S("@1 Stair Substructure", desc),
399 drawtype = "nodebox",
400 tiles = tiles,
401 paramtype = "light",
402 paramtype2 = "facedir",
403 --sunlight_propagates = true,
404 is_ground_content = false,
405 groups = groups,
406 node_box = {
407 type = "fixed",
408 fixed = {
409 {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
410 {-0.5, -0.5, 0.4375, 0.5, 0.4375, 0.5},
411 {-0.5, -0.4375, 0.375, 0.5, 0.4375, 0.4375},
412 {-0.5, -0.375, 0.3125, 0.5, 0.4375, 0.375},
413 {-0.5, -0.3125, 0.25, 0.5, 0.4375, 0.3125},
414 {-0.5, -0.25, 0.1875, 0.5, 0.4375, 0.25},
415 {-0.5, -0.1875, 0.125, 0.5, 0.4375, 0.1875},
416 {-0.5, -0.125, 0.0625, 0.5, 0.4375, 0.125},
417 {-0.5, -0.0625, 0, 0.5, 0.4375, 0.0625},
418 {-0.5, 0, -0.0625, 0.5, 0.4375, 0},
419 {-0.5, 0.0625, -0.125, 0.5, 0.4375, -0.0625},
420 {-0.5, 0.125, -0.1875, 0.5, 0.4375, -0.125},
421 {-0.5, 0.1875, -0.25, 0.5, 0.4375, -0.1875},
422 {-0.5, 0.25, -0.3125, 0.5, 0.4375, -0.25},
423 {-0.5, 0.3125, -0.375, 0.5, 0.4375, -0.3125},
424 {-0.5, 0.375, -0.4375, 0.5, 0.4375, -0.375},
427 on_place = on_place,
428 on_rotate = "simple",
429 sounds = sounds,
430 _hades_shaper_next = "columnia:column_stairsubpillar_"..mat,
433 minetest.register_node("columnia:column_stairsubpillar_"..mat, {
434 description = S("@1 Stair Substructure Pillar", desc),
435 drawtype = "nodebox",
436 tiles = tiles,
437 paramtype = "light",
438 paramtype2 = "facedir",
439 --sunlight_propagates = true,
440 is_ground_content = false,
441 groups = groups,
442 node_box = {
443 type = "fixed",
444 fixed = {
445 {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
446 {-0.5, -0.5, 0.4375, 0.5, 0.4375, 0.5},
447 {-0.5, -0.4375, 0.375, 0.5, 0.4375, 0.4375},
448 {-0.5, -0.375, 0.3125, 0.5, 0.4375, 0.375},
449 {-0.5, -0.3125, 0.25, 0.5, 0.4375, 0.3125},
450 {-0.5, -0.25, 0.1875, 0.5, 0.4375, 0.25},
451 {-0.5, -0.1875, 0.125, 0.5, 0.4375, 0.1875},
452 {-0.5, -0.125, 0.0625, 0.5, 0.4375, 0.125},
453 {-0.5, -0.0625, 0, 0.5, 0.4375, 0.0625},
454 {-0.5, 0, -0.0625, 0.5, 0.4375, 0},
455 {-0.5, 0.0625, -0.125, 0.5, 0.4375, -0.0625},
456 {-0.5, 0.125, -0.1875, 0.5, 0.4375, -0.125},
457 {-0.5, 0.1875, -0.25, 0.5, 0.4375, -0.1875},
458 {-0.5, 0.25, -0.3125, 0.5, 0.4375, -0.25},
459 {-0.5, 0.3125, -0.375, 0.5, 0.4375, -0.3125},
460 {-0.5, 0.375, -0.4375, 0.5, 0.4375, -0.375},
461 {-0.25, -0.5, -0.25, 0.25, 0.4375, 0.25},
464 on_place = on_place,
465 on_rotate = "simple",
466 sounds = sounds,
467 _hades_shaper_next = "columnia:column_stairsub_"..mat,