leskat

While...Do Error

Nov 17th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checkfortree(i)
  2.   turtle.select(16)
  3.   sleep(5)
  4.   local i = 0
  5.   if (turtle.compare() == true) then
  6.     i = 1
  7.     return i
  8.   end
  9. end
  10.  
  11. function minelayer()
  12.   turtle.digUp()
  13.   turtle.up()
  14.   turtle.dig()
  15.   turtle.forward()
  16.   turtle.turnRight()
  17.   turtle.dig()
  18.   turtle.forward()
  19.   turtle.turnRight()
  20.   turtle.dig()
  21.   turtle.forward()
  22.   turtle.turnRight()
  23.   turtle.forward()
  24.   turtle.turnRight()
  25. end
  26.  
  27. function minetree()
  28.   local i = 0
  29.   local hight = 0
  30.   turtle.dig()
  31.   turtle.forward()
  32.   turtle.dig()
  33.   turtle.forward()
  34.   turtle.turnRight()
  35.   turtle.dig()
  36.   turtle.forward()
  37.   turtle.turnRight()
  38.   turtle.dig()
  39.   turtle.forward()
  40.   turtle.turnRight()
  41.   turtle.forward()
  42.   turtle.turnRight()
  43.   while (i == 0) do
  44.     minelayer()
  45.     hight = hight + 1
  46.     turtle.select(16)
  47.     if (turtle.compareUp() == false) then
  48.       while (hight ~= 0) do
  49.         turtle.down()
  50.         hight = hight - 1
  51.       end
  52.       turtle.back()
  53.       i = 1
  54.     end
  55.   end
  56. end
  57.  
  58. function dumpitems()
  59.   local i = 0
  60.   local f = 1
  61.   turtle.turnLeft()
  62.   while (f < 14) do
  63.   turtle.select(f)
  64.     if (turtle.compareTo(16) == true) then
  65.       turtle.drop()
  66.     end
  67.     f = f + 1
  68.   end
  69.   turtle.turnRight()
  70. end
  71.  
  72. function replant()
  73.   turtle.select(15)
  74.   turtle.forward()
  75.   turtle.turnRight()
  76.   turtle.place()
  77.   turtle.turnLeft()
  78.   turtle.forward()
  79.   turtle.turnRight()
  80.   turtle.place()
  81.   turtle.turnLeft()
  82.   turtle.back()
  83.   turtle.place()
  84.   turtle.back()
  85.   turtle.place()
  86. end
  87.  
  88. while (true) do
  89.   local i = 0
  90.   checkfortree()
  91.   while (i == 0) do
  92.     i = minetree(i)
  93.   end
  94.   dumpitems()
  95.   replant()
  96. end
Advertisement
Add Comment
Please, Sign In to add comment