Advertisement
djPtica

farmTree

Jun 6th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. --farmTree by djPtica v0.1.1
  2. --SETUP
  3. --put saplings in slot 1
  4. --put turtle in front of bottom block of tree (or where tree is supposed to be)
  5. --put chest behind turtle
  6. --put stop block on 8th block where tree is gonna grow
  7.  
  8. function empty()
  9.    turtle.turnLeft()
  10.    turtle.turnLeft()
  11.    for i=2, 16 do
  12.       turtle.select(i)
  13.       turtle.drop()
  14.    end
  15.    turtle.turnLeft()
  16.    turtle.turnLeft()
  17. end
  18.  
  19. function plant()
  20.    turtle.select(1)
  21.    turtle.place()
  22. end
  23.  
  24. function cut()
  25.    turtle.dig()
  26.    turtle.forward()
  27.    turtle.digUp()
  28.    for i=1, 3 do
  29.       turtle.up()
  30.       turtle.digUp()
  31.    end
  32.    for i=1, 3 do
  33.       turtle.down()
  34.    end
  35.    turtle.back()
  36. end
  37.  
  38. function test()
  39.    for i=1, 12 do
  40.       j = turtle.getItemCount(1)
  41.       if j>1 then
  42.          return 1
  43.       else
  44.          if i==1 then
  45.             print("Nedovoljno saplinga (stavi saplinge u slot 1).")
  46.          end
  47.          sleep(5)
  48.       end
  49.    end
  50.    print("Nisu umetnuti potrebni resursi, obustavljam program...")
  51. end
  52.  
  53. --GLAVNI PROGRAM
  54.  
  55. k = 0
  56. k = test()
  57. while k do
  58.    plant()
  59.    turtle.up()
  60.    while not turtle.detect() do
  61.       sleep(2)
  62.    end
  63.    turtle.down()
  64.    cut()
  65.    empty()
  66.    k = test()
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement