Advertisement
wovelscotch

autoFell

May 26th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. --program that has a turtle check for trees over an 8x8 square of saplings. It takes wood back to a dump chest when full and picks up fuel when needed. it needs saplings in slot 16 to replant and wood in 15 to compare. Fuel goes in slot 13.
  2.  
  3. --chops down a tree when the turtle is positioned 1 block above the ground to clear the saplings.
  4. function chopTree()
  5.     if turtle.detect() == true then
  6.         local h = 0
  7.         turtle.dig()
  8.         turtle.forward()
  9.         turtle.digDown()
  10.         turtle.up()
  11.         turtle.select(16)
  12.         turtle.placeDown()
  13.         while turtle.compare(15) == true do
  14.             turtle.digUp()
  15.             h = h + 1
  16.         end
  17.         while h > 0 do
  18.             turtle.down()
  19.         end
  20.     end
  21. end
  22.  
  23. function patrolLine()
  24.     local i = 0
  25.     while i < 9 do
  26.         chopTree()
  27.         turtle.forward()
  28.         i = i + 1
  29.     end
  30. end
  31.  
  32. function patrolAll()
  33.     local i = 0
  34.     while i < 4 do
  35.         patrolLine()
  36.         turtle.turnRight()
  37.         turtle.forward()
  38.         turtle.turnRight()
  39.         patrolLine()
  40.         turtle.turnLeft()
  41.         turtle.forward()
  42.         turtle.turnLeft()
  43.         i = i + 1
  44.     end
  45.     i = 0
  46.     turtle.forward()
  47.     turtle.turnRight()
  48.     while i < 8 do
  49.         turtle.forward()
  50.         i = i + 1
  51.     end
  52. end
  53.  
  54. --dumps logs then refuels from a chest above it if needed
  55. function dumpLogs()
  56.     local i = 0
  57.     while i <= 13 do
  58.         turtle.select(i)
  59.         turtle.drop()
  60.         i = i + 1
  61.     end
  62.     turtle.up()
  63.     if turtle.getFuelLevel() > 200 then
  64.         turtle.select(13)
  65.         turtle.suck(64)
  66.         turtle.refuel()
  67.     end
  68.     turtle.down()
  69.     turtle.turnRight()
  70. end
  71.  
  72. function getFuel()
  73.     turtle.select(13)
  74.     turtle.refuel()
  75. end
  76.  
  77. --main
  78. getFuel()
  79. while turtle.getFuelLevel() >=50 do
  80.     patrolAll()
  81.     dumpLogs()
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement