4ndertheker

[FTB-Turtle] Potato-Farm

May 5th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.67 KB | None | 0 0
  1. wachstumsstandRechts=0
  2. wachstumsstandLinks=0
  3. local buds=50
  4.  
  5. local length=8
  6.  
  7. local function drop()
  8.     turtle.up()
  9.     turtle.up()
  10.     turtle.select(1)
  11.     if turtle.getItemCount(1)>16 then
  12.         turtle.dropUp(turtle.getItemCount(1)-16)
  13.     end
  14.     turtle.down()
  15.     turtle.down()
  16. end
  17.  
  18. local function harvestLeft()
  19.     if turtle.getItemCount(1)<16 then
  20.     print("Zu wenige Kartoffeln in Slot 1. Bitte nachfuellen und [Enter] Druecken.")
  21.     io.read()
  22.     end
  23.     turtle.select(1)
  24.     for i=1, length, 1 do
  25.         turtle.forward()
  26.         turtle.digDown()
  27.     end
  28.     turtle.turnRight()
  29.     turtle.turnRight()
  30.     for i=1, length, 1 do
  31.         turtle.placeDown()
  32.         turtle.forward()
  33.     end
  34.     turtle.turnLeft()
  35.     turtle.turnLeft()
  36. end
  37.  
  38. local function harvestRight()
  39.     if turtle.getItemCount(1)<16 then
  40.     print("Zu wenige Kartoffeln in Slot 1. Bitte nachfuellen und [Enter] Druecken.")
  41.     io.read()
  42.     end
  43.     turtle.select(1)
  44.     turtle.forward()
  45.     turtle.turnRight()
  46.     turtle.forward()
  47.     turtle.turnLeft()
  48.     for i=2, length, 1 do
  49.         turtle.digDown()
  50.         turtle.forward()
  51.     end
  52.     turtle.turnLeft()
  53.     turtle.turnLeft()
  54.     for i=2, length, 1 do
  55.     turtle.placeDown()
  56.     turtle.forward()
  57.     end
  58.     turtle.turnRight()
  59.     turtle.forward()
  60.     turtle.turnLeft()
  61.     turtle.forward()
  62.     turtle.turnLeft()
  63.     turtle.turnLeft()
  64. end
  65.  
  66. local function wait()
  67.     while true do
  68.         os.pullEvent("redstone")
  69.         if rs.getInput("right")==true then
  70.             wachstumsstandRechts=wachstumsstandRechts+1
  71.         end
  72.        
  73.         if wachstumsstandRechts>=buds then
  74.             harvestLeft()
  75.             wachstumsstandLinks=wachstumsstandLinks+3
  76.             wachstumsstandRechts=0
  77.             drop()
  78.  
  79.         end
  80.        
  81.         if rs.getInput("back")==true then
  82.             wachstumsstandLinks=wachstumsstandLinks+1
  83.         end
  84.  
  85.         if wachstumsstandLinks>=buds then
  86.             harvestLeft()
  87.             wachstumsstandRechts=wachstumsstandRechts+3
  88.             wachstumsstandLinks=0
  89.             drop()
  90.         end
  91.         local wsLeft=wachstumsstandLinks/buds*100
  92.         local wsRight=wachstumsstandRechts/buds*100
  93.         term.clear()
  94.         term.setCursorPos(1, 1)
  95.         print("Derzeitiger Wachstumsstatus:\n-links: ", wsLeft, "%")
  96.         print("-rechts: ", wsRight, "%")
  97.     end
  98. end
  99.  
  100. local function start()
  101.     if turtle.getItemCount(1)<16 then
  102.     print("Zu wenige Kartoffeln in Slot 1. Bitte nachfuellen und [Enter] Druecken.")
  103.     io.read()
  104.     end
  105.     turtle.select(1)
  106.     for i=1, length, 1 do
  107.         turtle.forward()
  108.         turtle.digDown()   
  109.         turtle.placeDown()
  110.     end
  111.     turtle.turnRight()
  112.     turtle.forward()
  113.     turtle.turnRight()
  114.     turtle.select(1)
  115.     for i=2, length, 1 do
  116.         turtle.digDown()
  117.         turtle.placeDown()
  118.         turtle.forward()
  119.     end
  120.     turtle.digDown()
  121.     turtle.placeDown()
  122.     turtle.turnRight()
  123.     turtle.forward()
  124.     turtle.turnLeft()
  125.     turtle.forward()
  126.     turtle.turnLeft()
  127.     turtle.turnLeft()
  128. end
  129. ------------------
  130. start()
  131. while true do
  132. wait()
  133. end
Advertisement
Add Comment
Please, Sign In to add comment