Orginalet

T2

Feb 8th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. -- Variables --
  2. fuel = 64
  3. length = 4
  4. rows = 4
  5. sapling = 1
  6. -- End Variables --
  7.  
  8.  
  9. -- Functions --
  10. function fuel() -- Let's the turtle refuel itself.
  11.   if turtle.getFuelLevel() < 30 then
  12.      turtle.select(16)
  13.      turtle.refuel(fuel)
  14.      turtle.select(sapling)
  15.   else
  16.      os.sleep(0.1)
  17.   end
  18. end
  19.  
  20. function move() -- Handles the turtle's movement function.
  21.   for i=1, length do
  22.      turtle.forward()
  23.      checktree()
  24.   end
  25. end
  26.  
  27. function navL() -- Navigates left.
  28.   turtle.turnLeft()
  29.   turtle.forward()
  30.   turtle.forward()
  31.   turtle.turnLeft()
  32.   turtle.placeDown()
  33. end
  34.  
  35. function navR() -- Navigates right.
  36.   turtle.turnRight()
  37.   turtle.forward()
  38.   turtle.forward()
  39.   turtle.turnRight()
  40.   turtle.placeDown()
  41. end
  42.  
  43. function log() -- Initiates the loggingturtle.
  44.   for i=1, rows do
  45.     move()
  46.     navL()
  47.     move()
  48.     navR()
  49.   end
  50. end
  51.  
  52. function scanlog() -- Scans for logs above turtle
  53.   if turtle.detectUp() == true then
  54.      while turtle.detectUp() == true do
  55.        turtle.digUp()
  56.        turtle.up()
  57.      end
  58.   else turtle.forward()
  59.   end
  60. end
  61.  
  62. function descend() -- Let's the turtle descend properly
  63.   while turtle.detectDown() ~= true do
  64.      turtle.down()
  65.      turtle.select(sapling)
  66.      turtle.placeDown()
  67.   end
  68. end
  69.  
  70. function checktree() -- Scans block in front, if it detects anything it breaks the block, otherwise move forward and try to place sapling
  71.   if turtle.detect() == true then
  72.      turtle.dig()
  73.      turtle.forward()
  74.      turtle.digDown()
  75.      scanlog()
  76.      descend()
  77.   else
  78.      turtle.forward()
  79.      turtle.select(sapling)
  80.      turtle.placeDown()
  81.   end
  82. end
  83. -- End Functions --
  84.  
  85. -- Execute code below this line --
  86. log()
Advertisement
Add Comment
Please, Sign In to add comment