-- wget https://mc.cortan122.de/cc/stairs.lua local mv = require("movement") local place_walls = true local building_block = "minecraft:polished_deepslate" local function placeOshaWall() if not place_walls then return end if not turtle.detect() then mv.placeItem(building_block, turtle.place) end end local function placeOshaWall_side(left, right) if place_walls then left() placeOshaWall() right() end end local function superDig() mv.dig() mv.forward() mv.digUp() mv.digDown() end local function placeTorch() mv.turnRight() mv.placeItem("torch", turtle.placeUp) mv.turnLeft() end local function placeStairs(left, right) mv.down() if not turtle.detectDown() then mv.placeItem(building_block, turtle.placeDown) end placeOshaWall_side(left, right) mv.up() mv.placeItem("stairs", turtle.placeDown) placeOshaWall_side(left, right) end local function digForward() mv.dig() mv.forward() end local function doubleWideStair(direction, direction_other) superDig() placeStairs(mv.turnRight, mv.turnLeft) direction(superDig) placeStairs(mv.turnLeft, mv.turnRight) mv.up() placeOshaWall_side(mv.turnLeft, mv.turnRight) mv.digUp() mv.up() placeOshaWall_side(mv.turnLeft, mv.turnRight) mv.digUp() direction_other(digForward) placeOshaWall_side(mv.turnRight, mv.turnLeft) mv.digUp() mv.down() placeOshaWall_side(mv.turnRight, mv.turnLeft) end local function placeFloor() if not turtle.detectDown() then mv.placeItem(building_block, turtle.placeDown) end end local function digWithFloor() mv.dig() mv.forward() mv.digUp() placeFloor() end local function doubleWideTunnel(direction) digWithFloor() direction(digWithFloor) end local function buildStairs(y_start, y_end) local dy = y_end - y_start local stairs = dy*2 local walls = stairs*4 print(string.format("we need %d torches", dy/6)) print(string.format("and we need %d stairs (%0.1f stacks)", stairs, stairs/64)) if place_walls then print(string.format("and we also need %d walls (%0.1f stacks)", walls, walls/64)) end for i=1,dy do doubleWideStair(mv.moveLeft, mv.moveRight) if i % 6 == 0 then placeTorch() end end end local function digTunnel(x_start, x_end) local dx = (x_end - x_start)/2 print(string.format("we need %d torches", dx/4)) for i=1,dx do doubleWideTunnel(mv.moveLeft) doubleWideTunnel(mv.moveRight) if i % 4 == 0 then placeTorch() end end end local function usage() print("usage: stairs [stairs|tunnel] [start_x] [end_x]") end local function main(args) if #args <= 1 or #args > 3 then usage() print("got the wrong number of args...") elseif args[1] == "stairs" then if #args == 3 then buildStairs(tonumber(args[2]), tonumber(args[3])) else buildStairs(0, tonumber(args[2])) end elseif args[1] == "tunnel" then if #args == 3 then digTunnel(tonumber(args[2]), tonumber(args[3])) else digTunnel(0, tonumber(args[2])) end else usage() print("unknown command...") end end local args = {...} main(args)