Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local width = 1
- local depth = 1
- local height = 4
- local upDown = ''
- --Handy movement functions
- local function upBy(num)
- for i=1, num do
- turtle.up()
- end
- end
- local function downBy(num)
- for i=1, num do
- turtle.down()
- end
- end
- local function leftBy(num)
- turtle.turnLeft()
- for i=1, num do
- turtle.forward()
- end
- turtle.turnRight()
- end
- local function rightBy(num)
- turtle.turnRight()
- for i=1, num do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- local function digHeight()
- for i=1, height do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- end
- end
- local function stairsDown()
- print("Witness me make a fine staircase that's " .. width .. " tiles wide, " .. height+1 .. " tiles tall, and goes down for " .. depth .. " levels");
- for d=1, depth do
- digHeight()
- downBy(height)
- -- Dig the horizontal width
- for i=1, width-1 do
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turtle.dig()
- digHeight()
- downBy(height)
- end
- turtle.forward()
- -- Dig blocks beneath the horizontal width
- for j=1, width do
- turtle.digDown()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- turtle.down()
- end
- end
- local function stairsUp()
- print("Witness me make a fine staircase that's " .. width .. " tiles wide, " .. height+1 .. " tiles tall, and goes up for " .. depth .. " levels");
- for d=1, depth do
- digHeight()
- downBy(height)
- -- Dig the horizontal width
- for i=1, width-1 do
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turtle.dig()
- digHeight()
- downBy(height)
- end
- turtle.forward()
- -- Dig blocks beneath the horizontal width
- for j=1, width do
- turtle.digUp()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- turtle.up()
- end
- end
- function main()
- if turtle.getFuelLevel() <= 0 then
- print("WARNING: Fuel is empty!")
- end
- print("Enter staircase width:")
- width = tonumber(read())
- print("Enter staircase height:")
- height = tonumber(read())
- print("Enter staircase depth:")
- depth = tonumber(read())
- print("Stairs up or down? (U/D)")
- upDown = tostring(read())
- if string.find(upDown, 'u') or string.find(upDown, 'U') then
- stairsUp()
- elseif string.find(upDown, 'd') or string.find(upDown, 'D') then
- stairsDown()
- else
- print("ERROR: Invalid input, cancelling mining operation.")
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment