Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --need to fix a couple things including a better sorting method
- --also sorts empty inventory immediately after going down after dropping off
- --perhaps auto sort occasionally(when empty slot is first filled by non-exclude?)
- --use above to drop entire stacks of junk continually instead of dropping everything once
- --variables
- length = 32
- width = 32
- depth = 70
- debug = true
- hasDropped = false
- turtX = 0
- turtY = 0
- turtZ = -1
- turtDir = 0 --0 forward, 1 left, 2 back, 3 right
- --functions
- function vals()
- term.clear()
- term.setCursorPos(1,1)
- print("Position: "..turtX..","..turtY..","..turtZ)
- print("Direction: "..turtDir)
- --sleep(1)
- end
- function up(x, dropping)
- x = x or 1
- dropping = dropping or false
- for i=1, x do
- while (turtle.up() == false) do
- turtle.digUp()
- turtle.attackUp()
- end
- turtY = turtY + 1
- if (debug) then
- vals()
- end
- if (dropping == false) then
- checkDrop()
- end
- end
- end
- function down(x, dropping)
- x = x or 1
- dropping = dropping or false
- for i=1, x do
- while (turtle.down() == false) do
- turtle.digDown()
- turtle.attackDown()
- end
- turtY = turtY - 1
- if (debug) then
- vals()
- end
- if (dropping == false) then
- checkDrop()
- end
- end
- end
- function left(x)
- x = x or 1
- for i=1, x do
- turtle.turnLeft()
- turtDir = turtDir + 1
- if (turtDir == 4) then
- turtDir = 0
- end
- if (debug) then
- vals()
- end
- end
- end
- function right(x)
- x = x or 1
- for i=1, x do
- turtle.turnRight()
- turtDir = turtDir - 1
- if (turtDir == -1) then
- turtDir = 3
- end
- if (debug) then
- vals()
- end
- end
- end
- function forward(x, dropping)
- x = x or 1
- dropping = dropping or false
- for i=1, x do
- while (turtle.forward() == false) do
- turtle.dig()
- turtle.attack()
- end
- if (turtDir == 0) then
- turtZ = turtZ + 1
- elseif (turtDir == 1) then
- turtX = turtX + 1
- elseif (turtDir == 2) then
- turtZ = turtZ - 1
- elseif (turtDir == 3) then
- turtX = turtX - 1
- end
- if (debug) then
- vals()
- end
- if (dropping == false) then
- checkDrop()
- end
- end
- end
- function checkDrop()
- if (turtle.getItemCount(15) > 0) then
- for s=1, 15 do
- turtle.select(s)
- if (turtle.compareTo(16) == true) then
- turtle.drop()
- end
- end
- if (hasDropped == true) then
- drop(turtX, turtY, turtZ, turtDir)
- else
- hasDropped = true
- end
- for a=1, 15 do
- turtle.select(a)
- for b=1, 15 do
- if (turtle.getItemCount(16 - b) == 0) then
- turtle.transferTo(16 - b)
- end
- end
- end
- turtle.select(1)
- end
- end
- function drop(oldX, oldY, oldZ, oldDir, x)
- x = x or false
- hasDropped = false
- up(-1 * oldY, true)
- while (turtDir ~= 3) do
- right()
- end
- forward(oldX, true)
- right()
- forward(oldZ + 1, true)
- for i=1, 15 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- right(2)
- if (x == false) then --keep going!
- forward(oldZ + 1)
- left()
- forward(oldX)
- down(-1 * oldY)
- while (turtDir ~= oldDir) do
- right()
- end
- else --done
- print("Done!")
- end
- end
- forward()
- for d=1, depth do
- for l=1, length do
- if (turtZ % 2 == 0) then
- left()
- forward(width - 1)
- right()
- else
- right()
- forward(width - 1)
- left()
- end
- if(l ~= length) then
- forward()
- end
- end
- right(2)
- if(d ~= depth) then
- down()
- end
- end
- drop(turtX, turtY, turtZ, turtDir, true)
Advertisement
Add Comment
Please, Sign In to add comment