Advertisement
kyle1320

Untitled

Mar 22nd, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. os.loadAPI("file")
  2.  
  3. dists = 1
  4. is = 1
  5. js = 1
  6.  
  7. fwd = function()
  8. refuel()
  9.  
  10. while turtle.detectUp()==true do
  11. turtle.digUp()
  12. end
  13.  
  14. turtle.digDown()
  15.  
  16. while turtle.forward()==false do
  17. turtle.dig()
  18. end
  19. end
  20.  
  21. refuel = function()
  22. if turtle.getFuelLevel()<20 then
  23. if turtle.getItemCount(16)==1 then
  24. print("out of fuel!")
  25. exit()
  26. end
  27.  
  28. turtle.select(16)
  29.  
  30. if turtle.refuel(1)==false then
  31. print("problem fueling!")
  32. exit()
  33. end
  34.  
  35. turtle.select(15)
  36. end
  37.  
  38. if turtle.getItemCount(15) == 1 then
  39. print("Out of chests!")
  40. exit()
  41. end
  42.  
  43. if isfull() then
  44. empty()
  45. end
  46. end
  47.  
  48. isfull = function()
  49. local full = true
  50.  
  51. for i=1,14 do
  52. if turtle.getItemCount(i)==0 then
  53. full = false
  54. end
  55. end
  56.  
  57. return full
  58. end
  59.  
  60. empty = function()
  61. turtle.digDown()
  62. turtle.select(15)
  63. turtle.placeDown()
  64. for i=1,14 do
  65. turtle.select(i)
  66. turtle.dropDown()
  67. end
  68. turtle.select(15)
  69. end
  70.  
  71. write = function(dist, i, j)
  72. file.write("state", {dist, i, j})
  73. end
  74.  
  75. spiral = function()
  76. dist = dists
  77.  
  78. turtle.select(15)
  79.  
  80. while true do
  81. dist = dist + 1
  82.  
  83. for i=is,2 do
  84. for j=js,dist do
  85. fwd()
  86. write(dist-1, i, j+1)
  87. end
  88. js = 1
  89. turtle.turnRight()
  90. write(dist-1, i+1, 1)
  91. end
  92. is = 1
  93. end
  94. end
  95.  
  96. start = function(dist, i, j)
  97. dists = dist
  98. is = i
  99. js = j
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement