Quetzi

Minecrew Lumberjack

Feb 18th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. local invalid = true
  2. local width = 2
  3. local height = 0
  4.  
  5. function chop()
  6.   turtle.select(1)
  7.   if width == 2 then
  8.     if turtle.detect() then
  9.       repeat turtle.dig() until turtle.forward()
  10.     end
  11.     while turtle.detect() do
  12.       turtle.dig()
  13.       turtle.turnRight()
  14.       if turtle.detect() then
  15.         turtle.dig()
  16.       end
  17.       turtle.turnLeft()
  18.       if turtle.detectUp() then
  19.         turtle.digUp()
  20.         repeat until turtle.up()
  21.         height=height+1
  22.       end
  23.     end
  24.     repeat until turtle.forward()
  25.     turtle.turnRight()
  26.     if turtle.detect() then
  27.       turtle.dig()
  28.     end
  29.     repeat until  turtle.forward()
  30.     turtle.turnLeft()
  31.     for i=1,height do
  32.      repeat turtle.digDown() until turtle.down()
  33.     end
  34.   end
  35.   repeat until turtle.back()
  36.   turtle.turnRight()
  37.   repeat until turtle.back()
  38.   turtle.turnLeft()
  39.   repeat until turtle.back()
  40. end
  41. function replant()
  42.   for i=1,15 do
  43.     turtle.select(i)
  44.     if turtle.compareTo(16) and turtle.getItemCount(i) >3 then
  45.       repeat until turtle.up()
  46.       for i=1,2 do
  47.         repeat until turtle.forward()
  48.         turtle.placeDown()
  49.       end
  50.       for i=1,2 do
  51.         turtle.turnRight()
  52.         repeat until turtle.forward()
  53.         turtle.placeDown()
  54.       end
  55.       repeat until turtle.forward()
  56.       turtle.turnRight()
  57.       repeat until turtle.forward()
  58.       repeat until turtle.down()
  59.       turtle.turnRight()
  60.       break
  61.     end
  62.   end
  63.   print("Ran out of saplings!")
  64. end
  65. function refuel()
  66.   if turtle.getFuelLevel() < 200 then
  67.     for i=1,15 do
  68.       turtle.select(i)
  69.       if not turtle.compareTo(16) then
  70.         turtle.refuel()
  71.       end
  72.     end
  73.   end
  74. end
  75.  
  76. function empty()
  77.   turtle.turnRight()
  78.   for i=1,15 do
  79.     turtle.select(i)
  80.     if not turtle.compareTo(16) then
  81.       turtle.drop()
  82.     end
  83.   end
  84.   turtle.turnLeft()
  85. end
  86.  
  87. while true do
  88.   turtle.select(16)
  89.   print("Has the tree grown yet?")
  90.   if not turtle.compare() then
  91.     print("w00t tree has grown! Lets get wood!")
  92.     height = 0
  93.     chop()
  94.     print("Replanting saplings")
  95.     replant()
  96.     print("Checking fuel and refuelling")
  97.     refuel()
  98.     print("Deposit our wood in the chest")
  99.     empty()
  100.   end
  101.   print("Waiting a minute for the tree to grow")
  102.   sleep(60)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment