Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- dist = args[1]
- run = true
- torchDistance = 1
- currentDistance = 0
- width = 1
- placeTorches = true
- turtle.select(14)
- turtle.refuel()
- turtle.select(1)
- print("Welcome! Current fuel: ", turtle.getFuelLevel())
- print("Enter the distance as an integer...")
- maxDistance = io.read()
- maxDistance = tonumber(maxDistance)
- print("Enter torch distance as an integer...")
- maxTorchDistance = io.read()
- maxTorchDistance = tonumber(maxTorchDistance)
- print("Enter width as an integer...")
- maxWidth = io.read()
- maxWidth = tonumber(maxWidth)
- if maxTorchDistance == 0 then
- print("Okay, I won't place torches.")
- placeTorches = false
- end
- function placeTorch()
- if turtle.getItemCount(15) > 0 then
- if torchDistance >= maxTorchDistance then
- print("Setting Torch")
- turtle.select(15)
- print(turtle.place())
- turtle.select(1)
- torchDistance = 0
- else
- print("Not placing torch. " , torchDistance , "<" , maxTorchDistance)
- end
- else
- print("Warning: No torches!!")
- end
- end
- function digSide()
- for width = 1, maxWidth do
- print("Current Width: ", width)
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- for width = 1, maxWidth do
- turtle.back()
- if placeTorches and not torchAlreadyPlaced then
- placeTorch()
- torchAlreadyPlaced = true
- end
- end
- torchAlreadyPlaced = false
- end
- if turtle.getFuelLevel() < maxDistance*5 then
- print("WARNING: turtle may not have the fuel to move the entire distance required")
- end
- print("Starting mine")
- while run do
- if turtle.getFuelLevel() <= 0 then
- print("NO FUEL. Stopping.")
- break
- end
- print("Distance: " , currentDistance)
- print("TorchDistance: " , torchDistance)
- print("Dig front side")
- while turtle.detect() do
- turtle.dig()
- end
- turtle.digUp()
- turtle.digDown()
- if maxWidth > 0 then
- print("Dig right side")
- turtle.turnRight()
- digSide()
- turtle.turnLeft()
- end
- if maxWidth > 0 then
- print("Dig left side")
- turtle.turnLeft()
- digSide()
- turtle.turnRight()
- end
- if turtle.getItemCount(13) > 0 then
- print("nearly full, chest dumping")
- turtle.select(16)
- turtle.placeDown()
- for a = 1, 14 do
- turtle.select(a)
- turtle.dropDown()
- end
- if turtle.getItemCount(16) < 0 then
- print("Out of chests!! Stopping")
- break
- end
- turtle.select(1)
- end
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- currentDistance = currentDistance + 1
- torchDistance = torchDistance + 1
- if currentDistance >= maxDistance then
- print("Max distance of " , maxDistance , " reached. Stopping")
- run = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement