Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("ok")
- local origin = {0,0,0}
- local max = {72,2,144}
- local dir = 1;
- local modX = {0,1,0,-1}
- local modZ = {-1,0,1,0}
- local location = {0,0,0}
- function turnAround()
- right()
- right()
- end
- function right()
- dir = dir + 1 % 5
- turtle.turnRight()
- end
- function left()
- dir = dir - 1
- if dir < 1 then
- dir = 1
- end
- turtle.turnLeft()
- end
- function down(dig)
- while true do
- if turtle.down() then
- break
- end
- if turtle.detectDown() then
- if dig then
- turtle.digDown()
- end
- end
- sleep(0)
- end
- location[1]=location[1]-1
- end
- function up(dig)
- while true do
- if turtle.up() then
- break
- end
- if dig then
- if turtle.detectUp() then
- turtle.digUp()
- end
- end
- sleep(0)
- end
- location[2] = location[2] + 1
- end
- function forward(dig)
- while true do
- if turtle.forward() then
- break
- end
- if turtle.detect() then
- if dig then
- turtle.dig()
- end
- end
- sleep(0)
- end
- print(dir);
- location[1] = location[1] + modX[dir];
- location[3] = location[3] + modZ[dir];
- end
- function back(dig)
- while true do
- if turtle.back() then
- break
- end
- if dig then
- turnAround()
- if turtle.detect() then
- turtle.dig()
- end
- turnAround()
- end
- sleep(0)
- end
- location[1] = location[1]+modX[dir];
- location[3] = location[3]+modZ[dir];
- end
- function getLocCopy()
- local copy = {}
- for i,n in ipairs(location) do
- copy[i]=n
- end
- return copy;
- end
- function checkInventory()
- if turtle.getItemCount(9) > 0 then
- return true
- end
- return false
- end
- function dropOff(x,y,z)
- local org = getLocCopy()
- if z%2 == 1 then
- left()
- forward(false)
- right()
- end
- while dir~=2 do
- left()
- sleep(0)
- end
- while location[3] ~= origin[3] do
- forward(false)
- sleep(0)
- end
- if location[1] ~= origin[1] then
- local left = false
- if location[1] <0 then
- left()
- left = true
- elseif location[1]>0 then
- right()
- end
- while location[1] ~= origin[1] do
- forward(false)
- sleep(0)
- end
- if left then
- right()
- else
- left()
- end
- end
- forward(false)
- forward(false)
- dropAll()
- turnAround()
- forward(false)
- forward(false)
- if left then
- left()
- else
- right()
- end
- while location[1] ~= org[1] do
- forward(false)
- sleep(0)
- end
- if left then
- right()
- else
- left()
- end
- if org[3] % 2 == 1 then
- right()
- forward(false)
- left()
- end
- while location[3]~=org[3] do
- forward(false)
- sleep(0)
- end
- if org[3]%2==1 then
- left()
- forward(true)
- right()
- end
- end
- function dropAll()
- for i=1,9,1 do
- turtle.select(i)
- if turtle.getItemCount(i) >0 then
- turtle.drop(turtle.getItemCount(i));
- end
- end
- end
- local input = ""
- while input ~= "start" do
- input = io.read()
- sleep(0)
- end
- local location = {0,0,0}
- for x=0,max[1],1 do
- for z=0,max[3],1 do
- for y=1,max[2]-1,1 do
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0)
- end
- checkInventory()
- print(tostring(x).."/"..tostring(y).."/"..tostring(z))
- end
- forward(true);
- if checkInventory() then
- dropOff(x,y,z)
- end
- end
- left()
- forward(true)
- left()
- back(true)
- end
Advertisement
Add Comment
Please, Sign In to add comment