Advertisement
1amw31rd

ComputerCraft - Tree Logger

Apr 30th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. --vars
  2. local count = 0
  3. local dist = 0
  4. --functions
  5. function cuttree()
  6.     count = 0
  7.     turtle.select(3)
  8.     turtle.dig()
  9.     if turtle.forward() == false then
  10.         turtle.select(1)
  11.         return
  12.     end
  13.     while turtle.digUp() == true do
  14.         turtle.up()
  15.         count = count + 1
  16.     end
  17.     for i=1,count,1 do
  18.         turtle.down()
  19.     end
  20.     turtle.back()
  21.     turtle.select(1)
  22.     turtle.place()
  23.  
  24.     while turtle.getItemCount(1) < 5 do
  25.         print("Low on saplings! Place a stack of saplings in slot 1!")
  26.         sleep(5)
  27.     end
  28. end
  29.  
  30. function Checkloop()
  31.     while true do
  32.         --dist = 0
  33.         while true do
  34.             turtle.turnLeft()
  35.             suck()
  36.             turtle.select(2)
  37.             if turtle.compare() == true then
  38.                 cuttree()
  39.             end
  40.             turtle.turnRight()
  41.             turtle.select(2)
  42.            
  43.             if turtle.forward() == false then
  44.                 break
  45.             end
  46.  
  47.             --dist = dist+1
  48.         end
  49.         turtle.turnRight()
  50.         turtle.turnRight()
  51.         --for i=1,dist,1 do
  52.         while turtle.forward() == true do
  53.             suck()
  54.         end
  55.         turtle.turnLeft()
  56.         for i = 3,16,1 do
  57.             turtle.select(i)
  58.             turtle.drop()
  59.         end
  60.         turtle.turnLeft()
  61.         suck()
  62.         turtle.select(2)
  63.         sleep(300)
  64.     end
  65. end
  66.  
  67. function suckIfNotFull(slot)
  68.     turtle.select(slot)
  69.     if turtle.getItemSpace(slot)  > 0 then
  70.         turtle.suckDown()
  71.     end
  72. end
  73.  
  74. function suck()
  75.     turtle.select(1)
  76.     while turtle.suck()==true do end
  77.     while turtle.suckDown()==true do end
  78. end
  79.  
  80. function initCheckSlots()
  81.     while turtle.getItemCount(1) == 0 or turtle.getItemSpace(1) > 32 do
  82.         print("Please put a half+ stack of saplings in slot 1!")
  83.         sleep(2)
  84.     end
  85.     while turtle.getItemCount(2) == 0 do
  86.         print("Please put a single block of wood in slot 2!")
  87.         sleep(2)
  88.     end
  89.  
  90.     print("Make sure there is a chest to the right of me currently...")
  91.     sleep(3)
  92.     print("Starting logger...")
  93. end
  94.  
  95. initCheckSlots()
  96. Checkloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement