Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function stripDig()
- for i = 1, 3 do
- turtle.dig()
- if not turtle.forward() then
- while true do
- turtle.dig()
- if turtle.forward() then break end
- end
- end
- turtle.digDown()
- end
- stripIterate(true)
- end
- function stripIterate(bool)
- if bool then
- turtle.turnLeft()
- end
- for i = 1, 5 do
- turtle.dig()
- if i < 5 then
- if not turtle.forward() then
- while true do
- turtle.dig()
- if turtle.forward() then break end
- end
- end
- else
- turtle.turnRight()
- turtle.turnRight()
- for j = 1, i-1 do
- if not turtle.forward() then
- while true do
- turtle.dig()
- if turtle.forward() then break end
- end
- end
- end
- if bool then
- stripIterate(false)
- else
- turtle.turnRight()
- end
- end
- end
- end
- function strip()
- print("How many iterations to dig the tunnel for?")
- -- 1 iteration is 3 blocks long including the block where the turtle is placed
- -- each iteration has a branch on both sides at the 3rd block at head height
- -- Note: The turtle must be placed on the ground, and will not dig a branch on the starting block
- -- Note: Turtle must have torches in selected slot
- local length = tonumber(read())
- turtle.digUp()
- turtle.up()
- for i = 0, length-1 do
- if i % 3 == 0 or i == length then
- turtle.placeDown()
- end
- stripDig()
- end
- turtle.turnRight()
- turtle.turnRight()
- for i = 0, (length*3)-2 do
- turtle.forward()
- end
- turtle.down()
- turtle.digDown()
- turtle.down()
- print("Finished strip mining")
- end
- function stairs()
- print("Enter current Y coordinate value: ")
- top = tonumber(read())
- print("Enter desired Y value above bedrock (0): ")
- bottom = tonumber(read())
- if bottom > top or top > 255 or bottom < 0 then
- term.clear()
- term.setCursorPos(1, 1)
- print("Warning: Incorrect input. Please try again")
- stairs()
- else
- function moveForward()
- if not turtle.forward() then
- while true do
- turtle.dig()
- if turtle.forward() then break end
- end
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- length = top - bottom
- length = math.ceil(length/2) * 2
- print("Digging from y="..top.." to y="..top-length)
- turtle.digDown()
- turtle.down()
- for i = 1, length/2 do
- if not turtle.detectDown() then
- turtle.select(2)
- turtle.placeDown();
- end
- moveForward()
- turtle.digDown()
- moveForward()
- turtle.dig()
- turtle.digDown()
- turtle.digUp()
- turtle.down()
- turtle.dig()
- turtle.digDown()
- turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- if not turtle.detect() then
- turtle.select(2)
- turtle.place();
- end
- turtle.turnRight()
- turtle.turnRight()
- print(math.floor((100 / (length / (i * 2))) * 100 + 0.5) / 100 .. "%")
- if i-1 % 3 == 0 then
- turtle.select(1)
- if not turtle.placeUp() then
- while true do
- turtle.digUp()
- if turtle.placeUp() then break end
- end
- end
- end
- end
- end
- turtle.dig()
- print("Finished digging stairs")
- end
- programs = {"stairs", "strip", "exit"}
- function getProg()
- print("Programs: ")
- for k, v in pairs(programs) do
- print(k.." - "..v)
- end
- prog = read()
- if prog == programs[1] and stairs ~= nil then
- term.clear()
- term.setCursorPos(1, 1)
- stairs()
- elseif prog == programs[2] and strip ~= nil then
- term.clear()
- term.setCursorPos(1, 1)
- strip()
- elseif prog == programs[#programs] then
- print("Goodbye")
- term.clear()
- term.setCursorPos(1, 1)
- else
- term.clear()
- term.setCursorPos(1, 1)
- print("Invalid program!")
- getProg()
- end
- end
- function start()
- term.clear()
- term.setCursorPos(1, 1)
- print("Enter password")
- pass = read()
- term.clear()
- term.setCursorPos(1, 1)
- if pass == "leo123" then
- print("Welcome. Type the name of a program to begin.")
- getProg()
- else
- print("Incorrect password!")
- start()
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement