Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x=1
- y=1
- z=1
- face=2 --n0 e1 s2 w3
- t=turtle
- xmax = 80 --EVEN NUMBERS RETARD
- ymax = 30
- zmax = 80
- function move()
- if t.forward() == false then
- t.attack("right")
- t.dig()
- move()
- end
- end
- function forceForward()
- if t.detect() then
- t.dig()
- end
- move()
- end
- function forceUp()
- if t.detectUp() then
- t.digUp()
- end
- t.up()
- end
- function forceDown()
- if t.detectDown() then
- t.digDown()
- end
- if t.down() == false then
- t.attack()
- forceDown()
- end
- end
- function left()
- t.turnLeft()
- if face == 0 then
- face = 3
- else
- face = face - 1
- end
- end
- function right()
- t.turnRight()
- if face == 3 then
- face = 0
- else
- face = face + 1
- end
- end
- function clean()
- while y < ymax do
- while x < xmax do
- while z < zmax do
- if t.detect() then
- dumpCheck()
- t.dig()
- end
- move()
- z = z + 1
- end
- if x%2 == 1 then
- right()
- t.dig()
- move()
- right()
- else
- left()
- t.dig()
- move()
- left()
- end
- x = x + 1
- z = 1
- end
- t.digUp()
- t.up()
- -- left()
- -- left()
- y = y + 1
- x = 1
- end
- end
- function dumpCheck()
- local i = 0
- local inv = 0
- while i < 16 do
- if t.getItemCount(i+1) ~= 0 then
- inv = inv + 1
- end
- i = i + 1
- end
- if inv > 14 then
- dump()
- end
- end
- function dump()
- tempx=x
- tempy=y
- tempz=z
- tempface = face
- --handling y
- while y > 1 do
- forceDown()
- y = y - 1
- end
- --handling x
- while face ~= 1 do
- left()
- end
- if tempy%2 == 1 then
- while x > 1 do
- forceForward()
- x = x - 1
- end
- else
- while x < xmax do
- forceForward()
- x = x + 1
- end
- end
- --handling z
- while face ~= 0 do
- left()
- end
- if tempx%2 == 1 then
- while z > 1 do
- forceForward()
- z = z - 1
- end
- else
- while z < zmax do
- forceForward()
- z = z + 1
- end
- end
- --At chest, now face East 1
- while face ~= 1 do
- left()
- end
- local i = 0
- for i = 16,1,-1 do
- t.select(i)
- t.drop()
- end
- --Returning to z
- while face ~= 2 do
- left()
- end
- if tempx%2 == 1 then
- while z < tempz do
- forceForward()
- z = z + 1
- end
- else
- while z > tempz do
- forceForward()
- z = z - 1
- end
- end
- --Returning to x
- while face ~= 3 do
- left()
- end
- if tempy%2 == 1 then
- while x < tempx do
- forceForward()
- x = x + 1
- end
- else
- while x > tempx do
- forceForward()
- x = x - 1
- end
- end
- --Returning to y
- while y < tempy do
- forceUp()
- y = y + 1
- end
- --Returning face
- while face ~= tempface do
- left()
- end
- end
- clean()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement