Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Branch Mine Main Corridor
- --Slots
- ---12, 13: Blocks
- ---14, 15: Torches
- ---16: Fuel
- --Declaring Variables
- local distance = 0
- local n = 0
- --Declaring Functions
- function dig()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- turtle.digDown()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function torch()
- turtle.select(14)
- if turtle.getItemCount(14) == 0 then
- turtle.select(15)
- end
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- end
- function fuel()
- if turtle.getFuelLevel() <= 50 then
- turtle.select(16)
- turtle.refuel(5)
- end
- end
- function block()
- turtle.select(13)
- if turtle.getItemCount(13) == 0 then
- turtle.select(14)
- end
- end
- function placeblockforward()
- if not turtle.detect() then
- turtle.place()
- end
- end
- function shaftleft()
- block()
- turtle.up()
- if not turtle.detectUp() then
- turtle.placeUp()
- end
- turtle.turnLeft()
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.turnRight()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- turtle.up()
- end
- function shaftmiddle()
- block()
- turtle.up()
- if not turtle.detectUp() then
- turtle.placeUp()
- end
- turtle.down()
- turtle.down()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- turtle.up()
- end
- function shaftright()
- block()
- turtle.up()
- if not turtle.detectUp() then
- turtle.placeUp()
- end
- turtle.turnRight()
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.turnLeft()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- turtle.up()
- end
- --Opening Instructions
- print("Welcome to the 3x3 Branch Mine Corridor v1.0!")
- sleep(1)
- print("Before we begin, make sure your turtle is positioned one block off of the floor of the corridor, on the right side, one block into the corridor.")
- sleep(1)
- print("Are you sure the turtle is positioned correctly?")
- sleep(1)
- print("Press any key to continue...")
- os.pullEvent("char")
- --Defining Length
- term.clear()
- term.setCursorPos(1,1)
- term.write("How long should the corridor be? ")
- distance = read()
- --Making the Right Corridor
- n = 0
- for i = 2, distance do
- fuel()
- dig()
- shaftright()
- n = n + 1
- if n == 4 then
- torch()
- n = 0
- end
- end
- --Right to Middle Transition
- turtle.turnLeft()
- dig()
- turtle.turnRight()
- block()
- turtle.up()
- if not turtle.detectUp() then
- turtle.placeUp()
- end
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.turnLeft()
- turtle.turnLeft()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- turtle.up()
- --Making the Middle Corridor
- for i = 2, distance do
- fuel()
- dig()
- shaftmiddle()
- end
- --Middle to Left Transition
- turtle.turnRight()
- dig()
- turtle.up()
- block()
- if not turtle.detectUp() then
- turtle.placeUp()
- end
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.down()
- placeblockforward()
- turtle.turnRight()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- turtle.up()
- --Making the Left Corridor
- n = 0
- for i = 2, distance do
- fuel()
- dig()
- shaftright()
- n = n + 1
- if n == 4 then
- torch()
- n = 0
- end
- end
- --Returning Home
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.down()
- for i = 1, distance do
- fuel()
- turtle.forward()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement