Advertisement
VADemon

Tree Destroyer 1.0

Sep 28th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. -- TreeDestroyer
  2. print("Fuel: ".. turtle.getFuelLevel())
  3. print("1 - 1x1 tree")
  4. print("2 - 2x2 tree")
  5. print("Press a key to start!")
  6. --DO NOT TOUCH THE CODE BELOW
  7.  
  8.  
  9. function cutUp()
  10.     turtle.digUp()
  11.     turtle.up()
  12. end
  13.  
  14. function cutDown()
  15.     turtle.digDown()
  16.     turtle.down()
  17. end
  18.  
  19. function runOne() --2x2
  20.     height = 0
  21.     heightFromFloor = 0
  22.    
  23.     -- chop down the first block
  24.     if turtle.dig() then
  25.         turtle.forward()
  26.     else
  27.         turtle.forward()
  28.         while turtle.up()==true do
  29.             heightFromFloor = heightFromFloor + 1
  30.         end
  31.     end
  32.  
  33.     while turtle.digUp()==true do
  34.         turtle.dig()
  35.         turtle.up()
  36.         height = height + 1 --count height of the tree
  37.     end
  38.  
  39.     turtle.turnRight(); turtle.dig(); turtle.forward(); turtle.turnLeft() --turn on the top
  40.  
  41.     for i=1, height do
  42.         cutDown()
  43.         turtle.dig()
  44.     end
  45.    
  46.     for i=1, heightFromFloor do
  47.         turtle.down()
  48.     end
  49.  
  50.     print("Jobs done! Current height: " ..height)
  51. end
  52.  
  53. function runOne() --1x1
  54.     height = 0
  55.     heightFromFloor = 1
  56.    
  57.     -- chop down the first block
  58.     if turtle.dig() then
  59.         turtle.forward()
  60.     else
  61.         turtle.forward()
  62.         while turtle.up()==true do
  63.             heightFromFloor = heightFromFloor + 1
  64.             if heightFromFloor >= 50 then -- dont go higher than 50 blocks
  65.                 break
  66.             end
  67.         end
  68.     end
  69.  
  70.     while turtle.digUp()==true do
  71.         turtle.dig()
  72.         turtle.up()
  73.         height = height + 1 --count height of the tree
  74.     end
  75.  
  76.     for i=1, height do
  77.         turtle.down()
  78.     end
  79.    
  80.     for i=1, heightFromFloor do
  81.         turtle.down()
  82.     end
  83.     print("Fuel: ".. turtle.getFuelLevel())
  84.     print("Jobs done! Current height: " ..height)
  85. end
  86.  
  87. function runTwo() --2x2
  88.     height = 0
  89.     heightFromFloor = 1
  90.    
  91.     -- chop down the first block
  92.     if turtle.dig() then
  93.         turtle.forward()
  94.     else
  95.         turtle.forward()
  96.         turtle.dig()
  97.         while turtle.up()==true do
  98.             heightFromFloor = heightFromFloor + 1
  99.             if heightFromFloor >= 50 then -- dont go higher than 50 blocks
  100.                 break
  101.             end
  102.         end
  103.     end
  104.  
  105.     while turtle.digUp()==true do
  106.         turtle.dig()
  107.         turtle.up()
  108.         height = height + 1 --count height of the tree
  109.     end
  110.  
  111.     turtle.turnRight(); turtle.dig(); turtle.forward(); turtle.turnLeft() --turn on the top
  112.  
  113.     for i=1, height do
  114.         cutDown()
  115.         turtle.dig()
  116.     end
  117.    
  118.     for i=1, heightFromFloor do
  119.         turtle.down()
  120.     end
  121.     print("Fuel: ".. turtle.getFuelLevel())
  122.     print("Jobs done! Current height: " ..height)
  123. end
  124.  
  125.  
  126.  
  127.  
  128. while true do
  129.     local event, char = os.pullEvent("char")
  130.         if char == "s" then
  131.             print("Quit!")
  132.             error()
  133.         elseif char == "1" then -- go
  134.             print("Die, 1x1 tree!")
  135.             runOne()
  136.             break
  137.         elseif char == "2" then
  138.             print("Die, 2x2 tree!")
  139.             runTwo()
  140.             break
  141.         end
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement