Advertisement
oWave

Chopper_no_bm_v2

Jul 10th, 2013
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local function checkFuel()
  2.     if turtle.getFuelLevel() < 1 then
  3.         turtle.select(2)
  4.         turtle.refuel(1)
  5.     end
  6. end
  7.  
  8. -- Move Functions
  9. local function Up()
  10.     checkFuel()
  11.     turtle.up()
  12. end
  13.  
  14. local function Down()
  15.     checkFuel()
  16.     turtle.down()
  17. end
  18.  
  19. local function Forward()
  20.     checkFuel()
  21.     if turtle.forward() then
  22.         return true
  23.     end
  24. end
  25.  
  26. local function Back()
  27.     checkFuel()
  28.     turtle.back()
  29. end
  30.  
  31. local function Right()
  32.     turtle.turnRight()
  33. end
  34.  
  35. local function Left()
  36.     turtle.turnLeft()
  37. end
  38.  
  39. local function Turn()
  40.     turtle.turnLeft()
  41.     turtle.turnLeft()
  42. end
  43.  
  44. local function Start()
  45.     turtle.dig()
  46.     Forward()
  47. end
  48.  
  49. local function FellUp()
  50.     up = 0
  51.     while turtle.detectUp() do
  52.         turtle.dig()
  53.         turtle.digUp()
  54.         Up()
  55.         up = up + 1
  56.     end
  57. end
  58.  
  59. local function Move()
  60.     turtle.dig()
  61.     Right()
  62.     turtle.dig()
  63.     Forward()
  64.     Left()
  65. end
  66.  
  67. local function FellDown()
  68.     while up > 0 do
  69.         turtle.dig()
  70.         turtle.digDown()
  71.         Down()
  72.         up = up - 1
  73.     end
  74.     turtle.dig()
  75. end
  76.  
  77. local function Place()
  78.     turtle.select(1)
  79.     turtle.placeDown()
  80. end
  81. local function Plant()
  82.     Up()
  83.     Place()
  84.     Forward()
  85.     Place()
  86.     Left()
  87.     Forward()
  88.     Place()
  89.     Left()
  90.     Forward()
  91.     Place()
  92.     Forward()
  93.     Down()
  94. end
  95.  
  96. local function GetSap()
  97.     NeedSap = 64 - turtle.getItemCount(1) -- How many
  98.     Left()
  99.     turtle.select(1)
  100.     turtle.suck(NeedSap)
  101. end
  102.  
  103. local function Drop()
  104.     Turn()
  105.     for i = 3,16 do
  106.         turtle.select(i)
  107.         turtle.drop()
  108.     end
  109.     Drop2 = turtle.getItemCount(2) - 5 -- Keeps 5 wood as fuel
  110.     if Drop2 < 0 then
  111.         Drop2 = 0
  112.     end
  113.     turtle.select(2)
  114.     turtle.drop(Drop2)
  115.  Right()
  116. end
  117.  
  118. local function CheckTree()
  119.     turtle.select(1)
  120.     while turtle.compare() do
  121.     sleep(0.5)
  122.     end
  123. end
  124.  
  125. local function CheckSap()
  126.     if turtle.getItemCount(1) < 5 then
  127.         print "Not enough saplings"
  128.         while turtle.getItemCount(1) < 5 do
  129.             sleep(0.5)
  130.         end
  131.         print "\nResuming"
  132.     end
  133. end
  134.  
  135. while true do
  136.     CheckSap()
  137.     CheckTree() -- Freezes the program until a tree is detected
  138.     Start()
  139.     FellUp()
  140.     Move()
  141.     FellDown()
  142.     Plant()
  143.     GetSap()
  144.     Drop()
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement