Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("file")
- dists = 1
- is = 1
- js = 1
- fwd = function()
- refuel()
- while turtle.detectUp()==true do
- turtle.digUp()
- end
- turtle.digDown()
- while turtle.forward()==false do
- turtle.dig()
- end
- end
- refuel = function()
- if turtle.getFuelLevel()<20 then
- if turtle.getItemCount(16)==1 then
- print("out of fuel!")
- exit()
- end
- turtle.select(16)
- if turtle.refuel(1)==false then
- print("problem fueling!")
- exit()
- end
- turtle.select(15)
- end
- if turtle.getItemCount(15) == 1 then
- print("Out of chests!")
- exit()
- end
- if isfull() then
- empty()
- end
- end
- isfull = function()
- local full = true
- for i=1,14 do
- if turtle.getItemCount(i)==0 then
- full = false
- end
- end
- return full
- end
- empty = function()
- turtle.digDown()
- turtle.select(15)
- turtle.placeDown()
- for i=1,14 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(15)
- end
- write = function(dist, i, j)
- file.write("state", {dist, i, j})
- end
- spiral = function()
- dist = dists
- turtle.select(15)
- while true do
- dist = dist + 1
- for i=is,2 do
- for j=js,dist do
- fwd()
- write(dist-1, i, j+1)
- end
- js = 1
- turtle.turnRight()
- write(dist-1, i+1, 1)
- end
- is = 1
- end
- end
- start = function(dist, i, j)
- dists = dist
- is = i
- js = j
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement