local ns = rgt_world function ns.register_slab(def) def = table.copy(def) def._variants = nil rgt.register_node(def._name.."_slab", extend(def, { drawtype = "nodebox", node_box = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5} }, paramtype = "light", paramtype2 = "facedir" })) end function ns.update_stair(pos, basename, leaf) local node = minetest.get_node(pos) local neighbors = {} local dir local pipe for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do pipe = minetest.get_node(pos +offset) if minetest.get_item_group(pipe.name, basename.."_stair") > 0 then neighbors[#neighbors +1] = offset end end if #neighbors == 1 then node.name = basename.."_stair" node.param2 = minetest.dir_to_facedir(-neighbors[1]:rotate(vector.new(0, math.pi /2, 0))) minetest.swap_node(pos, node) elseif #neighbors > 1 then -- Just ue the first two neighbors. if neighbors[1].x ~= 0 and neighbors[2].x ~= 0 or neighbors[1].z ~= 0 and neighbors[2].z ~= 0 then node.name = basename.."_stair" node.param2 = minetest.dir_to_facedir(neighbors[1]) end minetest.swap_node(pos, node) end if not leaf then for _, x in ipairs(neighbors) do update_pipe(pos +x, true) end end end function ns.register_stair(def) def = table.copy(def) def._variants = nil def.groups[def._name.."_stair"] = 1 rgt.register_node(def._name.."_stair", extend(table.copy(def), { drawtype = "nodebox", node_box = { type = "fixed", fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}} }, paramtype = "light", paramtype2 = "facedir" })) rgt.register_node(def._name.."_stair_inner", extend(table.copy(def), { drawtype = "nodebox", node_box = { type = "fixed", fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 0, 0.5, 0.5}} }, paramtype = "light", paramtype2 = "facedir" })) rgt.register_node(def._name.."_stair_outer", extend(def, { drawtype = "nodebox", node_box = { type = "fixed", fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0.5, 0, 0.5, 0}} }, paramtype = "light", paramtype2 = "facedir" })) end function ns.register_all(def) ns.register_slab(def) ns.register_stair(def) end