Rename mobs mod to mcl_mobs
[MineClone/MineClone2.git] / mods / ITEMS / mcl_stairs / cornerstair.lua
blob33d52e9881a6ee729e52cd77a9e277963b8e56ea
1 -- Corner stairs handling
3 -- This code originally copied from the [mcstair] mod and merged into this mod.
4 -- This file is licensed under CC0.
6 mcl_stairs.cornerstair = {}
8 local get_stair_param = function(node)
9 local stair = minetest.get_item_group(node.name, "stair")
10 if stair == 1 then
11 return node.param2
12 elseif stair == 2 then
13 if node.param2 < 12 then
14 return node.param2 + 4
15 else
16 return node.param2 - 4
17 end
18 elseif stair == 3 then
19 if node.param2 < 12 then
20 return node.param2 + 8
21 else
22 return node.param2 - 8
23 end
24 end
25 end
27 local get_stair_from_param = function(param, stairs)
28 if param < 12 then
29 if param < 4 then
30 return {name = stairs[1], param2 = param}
31 elseif param < 8 then
32 return {name = stairs[2], param2 = param - 4}
33 else
34 return {name = stairs[3], param2 = param - 8}
35 end
36 else
37 if param >= 20 then
38 return {name = stairs[1], param2 = param}
39 elseif param >= 16 then
40 return {name = stairs[2], param2 = param + 4}
41 else
42 return {name = stairs[3], param2 = param + 8}
43 end
44 end
45 end
47 local stair_param_to_connect = function(param, ceiling)
48 local out = {false, false, false, false, false, false, false, false}
49 if not ceiling then
50 if param == 0 then
51 out[3] = true
52 out[8] = true
53 elseif param == 1 then
54 out[2] = true
55 out[5] = true
56 elseif param == 2 then
57 out[4] = true
58 out[7] = true
59 elseif param == 3 then
60 out[1] = true
61 out[6] = true
62 elseif param == 4 then
63 out[1] = true
64 out[8] = true
65 elseif param == 5 then
66 out[2] = true
67 out[3] = true
68 elseif param == 6 then
69 out[4] = true
70 out[5] = true
71 elseif param == 7 then
72 out[6] = true
73 out[7] = true
74 elseif param == 8 then
75 out[3] = true
76 out[6] = true
77 elseif param == 9 then
78 out[5] = true
79 out[8] = true
80 elseif param == 10 then
81 out[2] = true
82 out[7] = true
83 elseif param == 11 then
84 out[1] = true
85 out[4] = true
86 end
87 else
88 if param == 12 then
89 out[5] = true
90 out[8] = true
91 elseif param == 13 then
92 out[3] = true
93 out[6] = true
94 elseif param == 14 then
95 out[1] = true
96 out[4] = true
97 elseif param == 15 then
98 out[2] = true
99 out[7] = true
100 elseif param == 16 then
101 out[2] = true
102 out[3] = true
103 elseif param == 17 then
104 out[1] = true
105 out[8] = true
106 elseif param == 18 then
107 out[6] = true
108 out[7] = true
109 elseif param == 19 then
110 out[4] = true
111 out[5] = true
112 elseif param == 20 then
113 out[3] = true
114 out[8] = true
115 elseif param == 21 then
116 out[1] = true
117 out[6] = true
118 elseif param == 22 then
119 out[4] = true
120 out[7] = true
121 elseif param == 23 then
122 out[2] = true
123 out[5] = true
126 return out
129 local stair_connect_to_param = function(connect, ceiling)
130 local param
131 if not ceiling then
132 if connect[3] and connect[8] then
133 param = 0
134 elseif connect[2] and connect[5] then
135 param = 1
136 elseif connect[4] and connect[7] then
137 param = 2
138 elseif connect[1] and connect[6] then
139 param = 3
140 elseif connect[1] and connect[8] then
141 param = 4
142 elseif connect[2] and connect[3] then
143 param = 5
144 elseif connect[4] and connect[5] then
145 param = 6
146 elseif connect[6] and connect[7] then
147 param = 7
148 elseif connect[3] and connect[6] then
149 param = 8
150 elseif connect[5] and connect[8] then
151 param = 9
152 elseif connect[2] and connect[7] then
153 param = 10
154 elseif connect[1] and connect[4] then
155 param = 11
157 else
158 if connect[5] and connect[8] then
159 param = 12
160 elseif connect[3] and connect[6] then
161 param = 13
162 elseif connect[1] and connect[4] then
163 param = 14
164 elseif connect[2] and connect[7] then
165 param = 15
166 elseif connect[2] and connect[3] then
167 param = 16
168 elseif connect[1] and connect[8] then
169 param = 17
170 elseif connect[6] and connect[7] then
171 param = 18
172 elseif connect[4] and connect[5] then
173 param = 19
174 elseif connect[3] and connect[8] then
175 param = 20
176 elseif connect[1] and connect[6] then
177 param = 21
178 elseif connect[4] and connect[7] then
179 param = 22
180 elseif connect[2] and connect[5] then
181 param = 23
184 return param
187 --[[
188 mcl_stairs.cornerstair.add(name, stairtiles)
190 NOTE: This function is used internally. If you register a stair, this function is already called, no
191 need to call it again!
193 Usage:
194 * name is the name of the node to make corner stairs for.
195 * stairtiles is optional, can specify textures for inner and outer stairs. 3 data types are accepted:
196 * string: one of:
197 * "default": Use same textures as original node
198 * "woodlike": Take first frame of the original tiles, then take a triangle piece
199 of the texture, rotate it by 90° and overlay it over the original texture
200 * table: Specify textures explicitly. Table of tiles to override textures for
201 inner and outer stairs. Table format:
202 { tiles_def_for_outer_stair, tiles_def_for_inner_stair }
203 * nil: Equivalent to "default"
206 function mcl_stairs.cornerstair.add(name, stairtiles)
207 local node_def = minetest.registered_nodes[name]
208 local outer_tiles
209 local inner_tiles
210 if stairtiles == "woodlike" then
211 outer_tiles = table.copy(node_def.tiles)
212 inner_tiles = table.copy(node_def.tiles)
213 for i=2,6 do
214 if outer_tiles[i] == nil then
215 outer_tiles[i] = outer_tiles[i-1]
217 if inner_tiles[i] == nil then
218 inner_tiles[i] = inner_tiles[i-1]
221 local t = node_def.tiles[1]
222 outer_tiles[1] = t.."^("..t.."^[transformR90^mcl_stairs_turntexture.png^[makealpha:255,0,255)"
223 outer_tiles[2] = t.."^("..t.."^mcl_stairs_turntexture.png^[transformR270^[makealpha:255,0,255)"
224 outer_tiles[3] = t
225 inner_tiles[1] = t.."^("..t.."^[transformR90^(mcl_stairs_turntexture.png^[transformR180)^[makealpha:255,0,255)"
226 inner_tiles[2] = t.."^("..t.."^[transformR270^(mcl_stairs_turntexture.png^[transformR90)^[makealpha:255,0,255)"
227 inner_tiles[3] = t
228 elseif stairtiles == nil or stairtiles == "default" then
229 outer_tiles = node_def.tiles
230 inner_tiles = node_def.tiles
231 else
232 outer_tiles = stairtiles[1]
233 inner_tiles = stairtiles[2]
235 local outer_groups = table.copy(node_def.groups)
236 outer_groups.not_in_creative_inventory = 1
237 local inner_groups = table.copy(outer_groups)
238 outer_groups.stair = 2
239 outer_groups.not_in_craft_guide = 1
240 inner_groups.stair = 3
241 inner_groups.not_in_craft_guide = 1
242 local drop = node_def.drop or name
243 local after_dig_node = function(pos, oldnode)
244 local param = get_stair_param(oldnode)
245 local ceiling
246 if param < 12 then
247 ceiling = false
248 else
249 ceiling = true
251 local connect = stair_param_to_connect(param, ceiling)
252 local t = {
253 {pos = {x = pos.x, y = pos.y, z = pos.z + 2}},
254 {pos = {x = pos.x - 1, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z + 1}},
255 {pos = {x = pos.x - 2, y = pos.y, z = pos.z}}, {pos = {x = pos.x - 1, y = pos.y, z = pos.z}},
256 {pos = pos, connect = connect},
257 {pos = {x = pos.x + 1, y = pos.y, z = pos.z}}, {pos = {x = pos.x + 2, y = pos.y, z = pos.z}},
258 {pos = {x = pos.x - 1, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z - 1}},
259 {pos = {x = pos.x, y = pos.y, z = pos.z - 2}}
261 for i,v in ipairs(t) do
262 if not v.connect then
263 local node = minetest.get_node(v.pos)
264 local node_def = minetest.registered_nodes[node.name]
265 if not node_def then
266 return
268 if node_def.stairs then
269 t[i].stairs = node_def.stairs
270 t[i].connect = stair_param_to_connect(get_stair_param(node), ceiling)
271 else
272 t[i].connect = {false, false, false, false, false, false, false, false}
276 local swap_stair = function(index, n1, n2)
277 local connect = {false, false, false, false, false, false, false, false}
278 connect[n1] = true
279 connect[n2] = true
280 local node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[index].stairs)
281 minetest.swap_node(t[index].pos, node)
283 if t[3].stairs then
284 if t[7].connect[1] and t[3].connect[6] then
285 if t[3].connect[1] and t[1].connect[6] then
286 if t[2].connect[3] then
287 swap_stair(3, 1, 8)
288 elseif t[4].connect[7] then
289 swap_stair(3, 1, 4)
291 elseif t[3].connect[7] then
292 swap_stair(3, 4, 7)
293 elseif t[3].connect[3] then
294 swap_stair(3, 3, 8)
296 elseif t[7].connect[2] and t[3].connect[5] then
297 if t[3].connect[2] and t[1].connect[5] then
298 if t[4].connect[8] then
299 swap_stair(3, 2, 3)
300 elseif t[2].connect[4] then
301 swap_stair(3, 2, 7)
303 elseif t[3].connect[4] then
304 swap_stair(3, 4, 7)
305 elseif t[3].connect[8] then
306 swap_stair(3, 3, 8)
310 if t[8].stairs then
311 if t[7].connect[3] and t[8].connect[8] then
312 if t[8].connect[3] and t[9].connect[8] then
313 if t[4].connect[5] then
314 swap_stair(8, 2, 3)
315 elseif t[12].connect[1] then
316 swap_stair(8, 3, 6)
318 elseif t[8].connect[1] then
319 swap_stair(8, 1, 6)
320 elseif t[8].connect[5] then
321 swap_stair(8, 2, 5)
323 elseif t[7].connect[4] and t[8].connect[7] then
324 if t[8].connect[4] and t[9].connect[7] then
325 if t[12].connect[2] then
326 swap_stair(8, 4, 5)
327 elseif t[4].connect[6] then
328 swap_stair(8, 1, 4)
330 elseif t[8].connect[6] then
331 swap_stair(8, 1, 6)
332 elseif t[8].connect[2] then
333 swap_stair(8, 2, 5)
337 if t[11].stairs then
338 if t[7].connect[5] and t[11].connect[2] then
339 if t[11].connect[5] and t[13].connect[2] then
340 if t[12].connect[7] then
341 swap_stair(11, 4, 5)
342 elseif t[10].connect[3] then
343 swap_stair(11, 5, 8)
345 elseif t[11].connect[3] then
346 swap_stair(11, 3, 8)
347 elseif t[11].connect[7] then
348 swap_stair(11, 4, 7)
350 elseif t[7].connect[6] and t[11].connect[1] then
351 if t[11].connect[6] and t[13].connect[1] then
352 if t[10].connect[4] then
353 swap_stair(11, 6, 7)
354 elseif t[12].connect[8] then
355 swap_stair(11, 3, 6)
357 elseif t[11].connect[8] then
358 swap_stair(11, 3, 8)
359 elseif t[11].connect[4] then
360 swap_stair(11, 4, 7)
364 if t[6].stairs then
365 if t[7].connect[7] and t[6].connect[4] then
366 if t[6].connect[7] and t[5].connect[4] then
367 if t[10].connect[1] then
368 swap_stair(6, 6, 7)
369 elseif t[2].connect[5] then
370 swap_stair(6, 2, 7)
372 elseif t[6].connect[5] then
373 swap_stair(6, 2, 5)
374 elseif t[6].connect[1] then
375 swap_stair(6, 1, 6)
377 elseif t[7].connect[8] and t[6].connect[3] then
378 if t[6].connect[8] and t[5].connect[3] then
379 if t[2].connect[6] then
380 swap_stair(6, 1, 8)
381 elseif t[10].connect[2] then
382 swap_stair(6, 5, 8)
384 elseif t[6].connect[2] then
385 swap_stair(6, 2, 5)
386 elseif t[6].connect[6] then
387 swap_stair(6, 1, 6)
392 minetest.override_item(name, {
393 stairs = {name, name.."_outer", name.."_inner"},
394 after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
395 on_place = nil,
396 after_place_node = function(pos, placer, itemstack, pointed_thing)
397 local node = minetest.get_node(pos)
398 local ceiling = false
399 if pointed_thing.under.y > pointed_thing.above.y then
400 ceiling = true
401 if node.param2 == 0 then node.param2 = 20
402 elseif node.param2 == 1 then node.param2 = 23
403 elseif node.param2 == 2 then node.param2 = 22
404 elseif node.param2 == 3 then node.param2 = 21
407 local connect = stair_param_to_connect(get_stair_param(node), ceiling)
408 local t = {
409 {pos = {x = pos.x - 1, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z + 1}},
410 {pos = {x = pos.x - 1, y = pos.y, z = pos.z}}, {pos = pos, stairs = {name, name.."_outer", name.."_inner"}, connect = connect}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z}},
411 {pos = {x = pos.x - 1, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z - 1}},
413 for i,v in ipairs(t) do
414 if not v.connect then
415 local node = minetest.get_node(v.pos)
416 local node_def = minetest.registered_nodes[node.name]
417 if not node_def then
418 return
420 if node_def.stairs then
421 t[i].stairs = node_def.stairs
422 t[i].connect = stair_param_to_connect(get_stair_param(node), ceiling)
423 else
424 t[i].connect = {false, false, false, false, false, false, false, false}
428 local reset_node = function(n1, n2)
429 local connect = {false, false, false, false, false, false, false, false}
430 connect[n1] = true
431 connect[n2] = true
432 node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[5].stairs)
434 local swap_stair = function(index, n1, n2)
435 local connect = {false, false, false, false, false, false, false, false}
436 connect[n1] = true
437 connect[n2] = true
438 local node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[index].stairs)
439 t[index].connect = connect
440 minetest.swap_node(t[index].pos, node)
442 if connect[3] then
443 if t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then
444 swap_stair(4, 2, 3)
445 elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then
446 swap_stair(4, 3, 6)
448 if t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then
449 swap_stair(6, 1, 8)
450 elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then
451 swap_stair(6, 5, 8)
453 if t[4].connect[3] ~= t[6].connect[8] then
454 if t[4].connect[3] then
455 if t[2].connect[6] then
456 reset_node(1, 8)
457 elseif t[8].connect[2] then
458 reset_node(5, 8)
459 elseif t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then
460 swap_stair(2, 6, 7)
461 reset_node(1, 8)
462 elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then
463 swap_stair(2, 3, 6)
464 reset_node(1, 8)
465 elseif t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then
466 swap_stair(8, 2, 3)
467 reset_node(5, 8)
468 elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then
469 swap_stair(8, 2, 7)
470 reset_node(5, 8)
472 else
473 if t[2].connect[5] then
474 reset_node(2, 3)
475 elseif t[8].connect[1] then
476 reset_node(3, 6)
477 elseif t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then
478 swap_stair(2, 4, 5)
479 reset_node(2, 3)
480 elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then
481 swap_stair(2, 5, 8)
482 reset_node(2, 3)
483 elseif t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then
484 swap_stair(8, 1, 8)
485 reset_node(3, 6)
486 elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then
487 swap_stair(8, 1, 4)
488 reset_node(3, 6)
492 elseif connect[2] then
493 if t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then
494 swap_stair(2, 4, 5)
495 elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then
496 swap_stair(2, 5, 8)
498 if t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then
499 swap_stair(8, 2, 3)
500 elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then
501 swap_stair(8, 2, 7)
503 if t[2].connect[5] ~= t[8].connect[2] then
504 if t[2].connect[5] then
505 if t[6].connect[8] then
506 reset_node(2, 3)
507 elseif t[4].connect[4] then
508 reset_node(2, 7)
509 elseif t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then
510 swap_stair(6, 1, 8)
511 reset_node(2, 3)
512 elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then
513 swap_stair(6, 5, 8)
514 reset_node(2, 3)
515 elseif t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then
516 swap_stair(4, 4, 5)
517 reset_node(2, 7)
518 elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then
519 swap_stair(4, 1, 4)
520 reset_node(2, 7)
522 else
523 if t[6].connect[7] then
524 reset_node(4, 5)
525 elseif t[4].connect[3] then
526 reset_node(5, 8)
527 elseif t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then
528 swap_stair(6, 6, 7)
529 reset_node(4, 5)
530 elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then
531 swap_stair(6, 2, 7)
532 reset_node(4, 5)
533 elseif t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then
534 swap_stair(4, 2, 3)
535 reset_node(5, 8)
536 elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then
537 swap_stair(4, 3, 6)
538 reset_node(5, 8)
542 elseif connect[4] then
543 if t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then
544 swap_stair(6, 6, 7)
545 elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then
546 swap_stair(6, 2, 7)
548 if t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then
549 swap_stair(4, 4, 5)
550 elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then
551 swap_stair(4, 1, 4)
553 if t[4].connect[4] ~= t[6].connect[7] then
554 if t[4].connect[4] then
555 if t[8].connect[1] then
556 reset_node(6, 7)
557 elseif t[2].connect[5] then
558 reset_node(2, 7)
559 elseif t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then
560 swap_stair(8, 1, 8)
561 reset_node(6, 7)
562 elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then
563 swap_stair(8, 1, 4)
564 reset_node(6, 7)
565 elseif t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then
566 swap_stair(2, 4, 5)
567 reset_node(2, 7)
568 elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then
569 swap_stair(2, 5, 8)
570 reset_node(2, 7)
572 else
573 if t[8].connect[2] then
574 reset_node(4, 5)
575 elseif t[2].connect[6] then
576 reset_node(1, 4)
577 elseif t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then
578 swap_stair(8, 2, 3)
579 reset_node(4, 5)
580 elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then
581 swap_stair(8, 2, 7)
582 reset_node(4, 5)
583 elseif t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then
584 swap_stair(2, 6, 7)
585 reset_node(1, 4)
586 elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then
587 swap_stair(2, 3, 6)
588 reset_node(1, 4)
592 elseif connect[1] then
593 if t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then
594 swap_stair(8, 1, 8)
595 elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then
596 swap_stair(8, 1, 4)
598 if t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then
599 swap_stair(2, 6, 7)
600 elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then
601 swap_stair(2, 3, 6)
603 if t[2].connect[6] ~= t[8].connect[1] then
604 if t[2].connect[6] then
605 if t[4].connect[3] then
606 reset_node(1, 8)
607 elseif t[6].connect[7] then
608 reset_node(1, 4)
609 elseif t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then
610 swap_stair(4, 2, 3)
611 reset_node(1, 8)
612 elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then
613 swap_stair(4, 3, 6)
614 reset_node(1, 8)
615 elseif t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then
616 swap_stair(6, 6, 7)
617 reset_node(1, 4)
618 elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then
619 swap_stair(6, 2, 7)
620 reset_node(1, 4)
622 else
623 if t[4].connect[4] then
624 reset_node(6, 7)
625 elseif t[6].connect[8] then
626 reset_node(3, 6)
627 elseif t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then
628 swap_stair(4, 4, 5)
629 reset_node(6, 7)
630 elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then
631 swap_stair(4, 1, 4)
632 reset_node(6, 7)
633 elseif t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then
634 swap_stair(6, 1, 8)
635 reset_node(3, 6)
636 elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then
637 swap_stair(6, 5, 8)
638 reset_node(3, 6)
643 minetest.swap_node(pos, node)
646 minetest.register_node(":"..name.."_outer", {
647 description = node_def.description,
648 _doc_items_create_entry = false,
649 drawtype = "nodebox",
650 tiles = outer_tiles,
651 paramtype = "light",
652 paramtype2 = "facedir",
653 is_ground_content = false,
654 groups = outer_groups,
655 sounds = node_def.sounds,
656 node_box = {
657 type = "fixed",
658 fixed = {
659 {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
660 {-0.5, 0, 0, 0, 0.5, 0.5}
663 drop = drop,
664 stairs = {name, name.."_outer", name.."_inner"},
665 after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
666 _mcl_hardness = node_def._mcl_hardness,
668 minetest.register_node(":"..name.."_inner", {
669 description = node_def.description,
670 _doc_items_create_entry = false,
671 drawtype = "nodebox",
672 tiles = inner_tiles,
673 paramtype = "light",
674 paramtype2 = "facedir",
675 is_ground_content = false,
676 groups = inner_groups,
677 sounds = node_def.sounds,
678 node_box = {
679 type = "fixed",
680 fixed = {
681 {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
682 {-0.5, 0, 0, 0.5, 0.5, 0.5},
683 {-0.5, 0, -0.5, 0, 0.5, 0}
686 drop = drop,
687 stairs = {name, name.."_outer", name.."_inner"},
688 after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
689 _mcl_hardness = node_def._mcl_hardness,
692 if minetest.get_modpath("doc") then
693 doc.add_entry_alias("nodes", name, "nodes", name.."_inner")
694 doc.add_entry_alias("nodes", name, "nodes", name.."_outer")