Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ver Beta 1.0.0
- --Defining variables
- x = 0
- y = 64
- z = 0
- d = 1
- xh = x
- yh = y
- zh = z
- dh = d
- dx = {0, -1, 0, 1}
- dz = {1, 0, -1, 0}
- qSize = 8
- qColumns = 5
- qRows = 3
- qDug = 0
- qToDig = qColumns * qRows
- qCurrentRow = 1
- dropping = false
- --Defining main functions
- function quarry(xq, zq, size)
- goto(xq, 64, zq, 1)
- repeat down() until turtle.detectDown() or y == 5
- if y == 5 then
- dropoff(zh, yh, zh, dh, true)
- else
- layer(size)
- end
- while y > 5 do
- for i = 1, 3 do
- if y > 5 then
- down()
- end
- end
- layer(size)
- turtle.digUp()
- end
- qDug = qDug + 1
- dropoff(xh, yh, zh, dh, true)
- end
- function layer(size)
- for i = 1, size do
- for j = 1, size - 1 do
- digQ()
- end
- if i < size then
- if i % 2 == 0 then
- left()
- digQ()
- left()
- else
- right()
- digQ()
- right()
- end
- end
- end
- if size % 2 == 0 then
- right()
- else
- left()
- end
- end
- function dropoff(xs, ys, zs, ds, new)
- dropping = true
- term.clear()
- term.setCursorPos(1, 1)
- if new then
- print("Done with quarry #", qDug + 1, ".")
- else
- print("Inventory full. Unloading...")
- end
- goto(xh, yh, zh, dh)
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- if not new then
- goto(xs, ys, zs, ds)
- term.clear()
- term.setCursorPos(1, 1)
- print("Digging quarry #", qDug + 1, "...")
- end
- dropping = false
- end
- function goto(xd, yd, zd, dd)
- while y < yh + 2 do
- up()
- end
- if xd < x then
- repeat left() until d == 1
- elseif xd > x then
- repeat left() until d == 3
- end
- repeat forward() until xd == x
- if zd < z then
- repeat left() until d == 2
- elseif zd > z then
- repeat left() until d == 0
- end
- repeat forward() until z == zd
- repeat down() until y == yd
- repeat left() until d == dd
- end
- --Defining movement functions
- function forward(amount)
- if not amount then
- amount = 1
- end
- for i = 1, amount do
- repeat turtle.dig() until turtle.forward()
- x = x + dx[d + 1]
- z = z + dz[d + 1]
- end
- if not dropping and turtle.getItemCount(16) > 0 then
- dropoff(x, y, z, d)
- end
- end
- function right()
- turtle.turnRight()
- d = d + 1
- if d == 4 then d = 0 end
- end
- function left()
- turtle.turnLeft()
- d = d - 1
- if d == -1 then d = 3 end
- end
- function turnAround()
- left()
- left()
- end
- function up(amount)
- if not amount then
- amount = 1
- end
- for i = 1, amount do
- repeat turtle.digUp() until turtle.up()
- y = y + 1
- end
- end
- function down(amount)
- if not amount then
- amount = 1
- end
- for i = 1, amount do
- repeat turtle.digDown() until turtle.down()
- y = y - 1
- end
- end
- function digQ()
- repeat until not turtle.digDown()
- repeat until not turtle.digUp()
- forward()
- end
- --Run code
- while qDug < qToDig do
- local xToDig = -10 - ((math.floor(qDug / qRows)) * (qSize + 1))
- local zToDig = 8 + ((qCurrentRow - 1) * (qSize + 1))
- term.clear()
- term.setCursorPos(1, 1)
- print("Digging quarry #", qDug + 1, "...")
- quarry(xToDig, zToDig, qSize)
- qCurrentRow = qCurrentRow + 1
- if qCurrentRow > qRows then
- qCurrentRow = 1
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Done digging ", qDug, " quarries.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement