Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args={...}
- x=args[1]
- y=0
- j=1
- turn="Right"
- canMoveForward=function()
- while not turtle.forward() do
- if turtle.detect() then
- turtle.dig()
- else
- turtle.attack()
- end
- end
- j = j + 1
- end
- canMoveDown=function()
- while not turtle.down() do
- if turtle.detectDown() then
- turtle.digDown()
- else
- turtle.attackDown()
- end
- end
- end
- digLevel=function()
- for i=1, x do
- while j<tonumber(x) do
- canMoveForward()
- end
- if i<tonumber(x)
- then
- if turn=="Left"
- then
- turn="Right"
- turtle.turnLeft()
- canMoveForward()
- turtle.turnLeft()
- else
- turn="Left"
- turtle.turnRight()
- canMoveForward()
- turtle.turnRight()
- end
- else
- if turn=="Left"
- then
- turtle.turnRight()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- j=1
- end
- end
- print("Mining " .. x .. " x " .. x .. " mine")
- while not turtle.detectDown() or turtle.digDown() do
- digLevel()
- turn="Right"
- if turtle.getItemCount(16)>0
- then
- turtle.select(1)
- turtle.placeUp()
- for i=3, 16 do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.select(1)
- turtle.digUp()
- end
- if turtle.getFuelLevel()< (x * x)
- then
- turtle.select(2)
- turtle.placeUp()
- turtle.select(16)
- turtle.refuel()
- turtle.suckUp(1,1)
- turtle.select(2)
- turtle.digUp()
- end
- canMoveDown()
- y=y+1
- end
- digLevel()
- for i=1, y do
- turtle.up()
- end
- turtle.select(1)
- turtle.placeUp()
- for i=3, 16 do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.select(1)
- turtle.digUp()
- print( x .. " x " .. x .. " mine complete")
Advertisement
Add Comment
Please, Sign In to add comment