JDubbleu

Spruce Tree 2.0

Jan 23rd, 2021 (edited)
279
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function main()
  2.     io.write("Enter number of spruce trees to chop:\n")
  3.     numTrees=io.read()
  4.  
  5.     if turtle.getFuelLevel()<50*numTrees then
  6.         io.write("Not enough fuel for operation!\n")
  7.         return false
  8.     end
  9.  
  10.     for j=1,numTrees,1 do
  11.         i=0
  12.         while not turtle.up() do
  13.             level(i)
  14.             i=i+1
  15.         end
  16.         comeBack(i)
  17.  
  18.         if j~=numTrees then
  19.             turtle.dig()
  20.             turtle.forward()
  21.             turtle.turnRight()
  22.             turtle.dig()
  23.             turtle.forward()
  24.             turtle.turnLeft()
  25.         end
  26.     end
  27.  
  28.  
  29. end
  30.  
  31. function level(height)
  32.     turtle.dig()
  33.     turtle.digUp()
  34.     if height%2==0 then
  35.         turtle.turnRight()
  36.         turtle.dig()
  37.     else
  38.         turtle.turnLeft()
  39.         turtle.dig()
  40.     end
  41.     turtle.up()
  42. end
  43.  
  44. function comeBack(height)
  45.     turtle.forward()
  46.     if height%2==0 then
  47.         turtle.turnRight()
  48.     else
  49.         turtle.turnLeft()
  50.     end
  51.     turtle.dig()
  52.     turtle.forward()
  53.  
  54.     while height>=0 do
  55.         turtle.digDown()
  56.         turtle.down()
  57.         height=height-1
  58.     end
  59. end
  60.  
  61. main()
RAW Paste Data