Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pass = 0
- cols = 1
- rows = 1
- function turnLeft()
- turtle.digDown()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function turnRight()
- turtle.digDown()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function turnLeftDown()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.forward()
- end
- function turnRightDown()
- turtle.turnRight()
- turtle.turnRight()
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.forward()
- end
- function forward()
- turtle.digDown()
- turtle.forward()
- end
- function inventoryCheck()
- local usedSlots = 0
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- usedSlots = usedSlots + 1
- end
- end
- if usedSlots == 16 then return false end
- return true
- end
- function quary()
- while inventoryCheck() do
- if turtle.getFuelLevel() < 15 then
- turtle.refuel(1)
- end
- if pass % 2 == 0 then
- if cols == 8 and rows % 2 > 0 and rows < 8 then
- turnRight()
- rows = rows + 1
- cols = 1
- elseif cols == 8 and rows % 2 == 0 and rows < 8 then
- turnLeft()
- rows = rows + 1
- cols = 1
- elseif cols == 8 and rows == 8 then
- turnRightDown()
- rows = 1
- cols = 1
- pass = pass + 1
- else
- forward()
- cols = cols + 1
- end
- elseif pass % 2 > 0 then
- if cols == 8 and rows % 2 > 0 and rows < 8 then
- turnLeft()
- rows = rows + 1
- cols = 1
- elseif cols == 8 and rows % 2 == 0 and rows < 8 then
- turnRight()
- rows = rows + 1
- cols = 1
- elseif cols == 8 and rows == 8 then
- turnLeftDown()
- rows = 1
- cols = 1
- pass = pass + 1
- else
- forward()
- cols = cols + 1
- end
- end
- end
- end
- function unLoad()
- local oldPass = pass
- local oldCols = cols
- local oldRows = rows
- if turtle.getFuelLevel() < 15 then
- turtle.refuel(3)
- end
- -- Go to chest
- while pass ~= 0 do
- turtle.up()
- pass = pass - 1
- end
- turtle.up()
- if oldPass % 2 == oldRows % 2 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- while rows ~= 1 do
- turtle.forward()
- rows = rows - 1
- end
- turtle.turnLeft()
- while cols ~= 1 do
- turtle.forward()
- cols = cols - 1
- end
- -- End go to chest
- -- Empty invetory into chest
- for i = 2, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- -- End empty invetory into chest
- -- Go back
- turtle.turnLeft()
- turtle.turnLeft()
- while cols ~= oldCols do
- turtle.forward()
- cols = cols + 1
- end
- turtle.turnRight()
- while rows ~= oldRows do
- turtle.forward()
- rows = rows + 1
- end
- while pass ~= oldPass do
- turtle.down()
- pass = pass + 1
- end
- if oldPass % 2 == oldRows % 2 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- -- End go back
- end
- function process()
- while true do
- quary()
- unLoad()
- end
- end
- process()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement