Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local depth = 0
- local xPos,zPos = 0,0
- local xDir,zDir = 0,1
- local goTo
- local count = 0
- local chests = 0
- local function amount(_name)
- tName = "minecraft:" .. _name
- local tCount = 0
- for i=1,16 do
- local item = turtle.getItemDetail(i)
- if item ~= nil then
- if item.count > 0 and item.name == tName then
- tCount = tCount + item.count
- end
- end
- end
- return tCount
- end
- local function turnLeft()
- turtle.turnLeft()
- xDir, zDir = -zDir, xDir
- end
- local function turnRight()
- turtle.turnRight()
- xDir, zDir = zDir, -xDir
- end
- function goTo( x, y, z, xd, zd )
- while depth > y do
- if turtle.up() then
- depth = depth - 1
- else
- turtle.digUp()
- end
- end
- if xPos > x then
- while xDir ~= -1 do
- turnLeft()
- end
- while xPos > x do
- if turtle.forward() then
- xPos = xPos - 1
- else
- turtle.dig()
- end
- end
- elseif xPos < x then
- while xDir ~= 1 do
- turnLeft()
- end
- while xPos < x do
- if turtle.forward() then
- xPos = xPos + 1
- else
- turtle.dig()
- end
- end
- end
- if zPos > z then
- while zDir ~= -1 do
- turnLeft()
- end
- while zPos > z do
- if turtle.forward() then
- zPos = zPos - 1
- else
- turtle.dig()
- end
- end
- elseif zPos < z then
- while zDir ~= 1 do
- turnLeft()
- end
- while zPos < z do
- if turtle.forward() then
- zPos = zPos + 1
- else
- turtle.dig()
- end
- end
- end
- while depth < y do
- if turtle.down() then
- depth = depth + 1
- else
- turtle.digDown()
- end
- end
- if zd ~= xd then
- while zDir ~= zd or xDir ~= xd do
- turnRight()
- end
- end
- end
- -- start --
- count = amount("hopper")
- chests = amount("chest")
- if chests >= ((count * 2) + 2) then
- goTo(1, 1, -1, 0, -1)
- turtle.digUp() turtle.select(1) turtle.placeUp()
- goTo(0, 1, -1, 0, -1)
- turtle.digUp() turtle.placeUp()
- for i=1, count do
- goTo(0, (i+1), -2, 0, -1)
- turtle.digUp() turtle.placeUp()
- end
- goTo(0, (count+1), -1, 0, -1)
- goTo(0, 1, -1, 0, -1)
- goTo(1, 1, -1, 0, -1)
- for i=1, count do
- goTo(1, (i+1), -2, 0, -1)
- turtle.digUp() turtle.placeUp()
- end
- goTo(1, count+1, 0, 0, -1)
- goTo(1, 0, 0, 0, -1)
- for i=1, count do
- goTo(1, i, 0, 0, -1)
- turtle.dig() turtle.select(2) turtle.place()
- end
- goTo(0, 0, 0, 0, 1)
- turtle.select(1)
- print("Done!")
- if #tArgs > 0 then
- if tArgs[1] == "exf" then
- shell.run("exf 16")
- elseif tArgs[1] == "exc" then
- shell.run("excavate 16")
- end
- end
- else
- print("Not enough chests!")
- end
Add Comment
Please, Sign In to add comment