Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if #args ~= 3 then
- print("Usage: quarry <row length> <number of rows> <current y>")
- error()
- end
- rowLength = args[1]
- rows = args[2]
- startingY = args[3]
- curRow = 1
- y = startingY
- function full()
- fullSlots = 0
- for i=2,15 do
- if turtle.getItemCount(i) > 0 then
- fullSlots = fullSlots + 1
- end
- end
- print(fullSlots .. " slots are full")
- return(fullSlots == 14)
- end
- function checkFuel()
- if turtle.getFuelLevel() < 10 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function digMove()
- checkFuel()
- while turtle.detect() do
- turtle.dig()
- os.sleep(0.5)
- end
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- function turn()
- if curRow % 2 == 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- function dig()
- turtle.digDown()
- turtle.down()
- y = y - 1
- end
- function back()
- turtle.turnLeft()
- for i=1,rows do
- checkFuel()
- turtle.forward()
- end
- turtle.turnLeft()
- end
- function up()
- for i=1,(startingY - y) do
- checkFuel()
- turtle.up()
- y = y + 1
- end
- end
- function down(x)
- for i=1,x do
- checkFuel()
- dig(x)
- end
- end
- function chest()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=2,16 do
- turtle.select(i)
- turtle.drop()
- end
- if turtle.getItemCount(1) < 3 then
- turtle.up()
- turtle.select(1)
- turtle.suck()
- turtle.down()
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- function level()
- curRow = 1
- for i=1,rows do
- for i=1,rowLength-1 do
- digMove()
- end
- if curRow == tonumber(rows) then
- else
- turn()
- digMove()
- turn()
- curRow = curRow + 1
- end
- end
- back()
- tempY = y
- if full() then
- up()
- chest()
- down(startingY - tempY + 3)
- else
- down(3)
- end
- turtle.digDown()
- end
- function quarry()
- down(2)
- turtle.digDown()
- while y > 5 do
- level()
- end
- up()
- end
- quarry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement