4ndertheker

[FTB] [CC] small Tree 2.0

Sep 13th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. local detectInterval = 30
  2. local saplingSlot = 1
  3. local woodSlot = 2
  4.  
  5. function countSaplings()
  6.   while turtle.getItemCount(saplingSlot) <= 1 do
  7.     print("Zu wenige Saplings in Slot ", saplingSlot, ", bitte nachfuellen und [Enter] druecken")
  8.     read()
  9.   end
  10.  
  11.   while turtle.getItemCount(woodSlot) <= 0 do
  12.     print("Zu wenige Holzblöcke in Slot ", woodSlot, ", bitte nachfuellen und [Enter] druecken")
  13.     read()
  14.   end
  15. end
  16.  
  17. function start()
  18.  
  19.   turtle.select(saplingSlot)  
  20.  
  21.   countSaplings()
  22.  
  23.   if turtle.detect() ~= true then
  24.     print("Die Turtle erwartet den Block, auf dem der Baum wachsen wird, vor sich. Bitte Turtle repositionieren und das Script erneut starten.")
  25.     exit()
  26.   end
  27.  
  28.   turtle.up()
  29.   turtle.place()
  30.   turtle.down()
  31.  
  32. end
  33.  
  34. function wait()
  35.  
  36.   turtle.select(saplingSlot)
  37.  
  38.   if turtle.detect() ~= true then
  39.     print("Fehler: Turtle befindet sich nicht an der erwarteten Position!")
  40.       exit()
  41.   end
  42.  
  43.   while true do
  44.     for i = detectInterval, 0, -1 do
  45.       countSaplings()
  46.       turtle.suckDown()
  47.       sleep(1)
  48.     end
  49.     turtle.up()
  50.     turtle.digUp()
  51.     turtle.up()
  52.     if turtle.detect() == true then
  53.       turtle.down()
  54.       turtle.down()
  55.       break
  56.     else
  57.       turtle.down()
  58.       turtle.down()    
  59.     end  
  60.   end
  61.  
  62. end
  63.  
  64. function tree()
  65.   turtle.select(woodSlot)
  66.   turtle.up()
  67.   turtle.dig()
  68.   turtle.forward()
  69.   while turtle.compareUp() == true do
  70.     turtle.digUp()
  71.     turtle.up()
  72.   end
  73.   while turtle.down() == true do end
  74.   turtle.turnRight()
  75.   turtle.turnRight()
  76.   turtle.forward()
  77.   turtle.turnRight()
  78.   turtle.turnRight()
  79.   countSaplings()
  80.   turtle.select(1)
  81.   turtle.place()
  82.   turtle.down()
  83. end
  84.  
  85. function drop()
  86.   turtle.turnRight()
  87.   turtle.select(woodSlot)
  88.   turtle.drop(turtle.getItemCount(woodSlot)-1)
  89.  
  90.   for i = 3, 16, 1 do
  91.     turtle.select(i)
  92.     turtle.drop()
  93.   end
  94.  
  95.   turtle.turnLeft()
  96. end
  97.  
  98. start()
  99.  
  100. while true do
  101.   wait()
  102.   tree()
  103.   drop()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment