Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x, y, z, running, rot
- rot = "left"
- dir = "Top"
- function mine()
- if turtle.detect() then
- turtle.dig()
- sleep(0.5)
- mine()
- else
- turtle.forward()
- end
- end
- function turn()
- if rot == "left" then
- turtle.turnLeft()
- mine()
- turtle.turnLeft()
- rot = "right"
- else
- turtle.turnRight()
- mine()
- turtle.turnRight()
- rot = "left"
- end
- end
- function ascend()
- if dir == "top" then
- turtle.digUp()
- turtle.up()
- else
- turtle.digDown()
- turtle.down()
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- function checkFuelNeed()
- if turtle.getFuelLevel() < 1 then
- for i = 1, 16 do -- loop through the slots
- turtle.select(i) -- change to the slot
- if turtle.refuel(0) then -- if it's valid fuel
- turtle.refuel(1) -- consume half the stack as fuel
- return true
- end
- end
- return false
- end
- end
- function awaitFuel()
- while checkFuelNeed() == false do
- print "Please feed me!"
- os.sleep(5)
- end
- end
- function runMiner()
- for ly = y, 1, -1 do
- for lz = z, 1, -1 do
- for lx = x, 2, -1 do
- awaitFuel()
- mine()
- print "mine"
- end
- if lz ~= 1 then
- turn()
- print "turn"
- else
- print "Fail turn"
- end
- end
- if ly ~= 1 then
- ascend()
- print "ascend"
- else
- print "Fail ascend"
- end
- end
- print "Done"
- end
- function init()
- print("Please enter the width of the quary")
- x = read()
- print("Please enter the height of the quary")
- y = read()
- print("Please enter the depth of the quary")
- z = read()
- print("Please enter the direction to dig to (left|right)")
- rot = read()
- print("Please enter the direction to dig to (top|bottom)")
- dir = read()
- runMiner()
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment