Thunder7102

Tree Mine

May 24th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. --[[
  2.     A simple program that will mine out trees from top to bottom.
  3. ]]
  4.  
  5. local isBig = false
  6.  
  7. function treeLoop()
  8.     local height = 0
  9.    
  10.     --Basic going up code
  11.     while turtle.compareUp() do
  12.         height = height+1
  13.         turtle.digUp()
  14.         if isBig then turtle.dig() end
  15.         turtle.up()
  16.     end
  17.    
  18.     if isBig then
  19.         --A quick adjustment if the tree is a 2x2
  20.         turtle.turnRight()
  21.         turtle.fForward()
  22.         turtle.turnLeft()
  23.     end
  24.    
  25.     --Here is where we bring him down
  26.     for i=1,height do
  27.         turtle.digDown()
  28.         if isBig then turtle.dig() end
  29.         turtle.down()
  30.     end
  31.    
  32.     --A little pizzazz
  33.     if isBig then
  34.         --Just going to bring him back to start pos
  35.         turtle.turnLeft()
  36.         turtle.forward()
  37.         turtle.turnRight()
  38.     end
  39.    
  40.     --And he's done!
  41.     turtle.turnLeft()
  42.     turtle.turnLeft()
  43.     turtle.forward()
  44. end
  45.  
  46. function fuelCheck()
  47.     if turtle.getFuelLevel() < 99 then
  48.         return false
  49.     else
  50.         return true
  51.     end
  52. end
  53.  
  54. function startup()
  55.     turtle.fForward()
  56.     turtle.select(1)
  57.     if turtle.compare() then
  58.         isBig = true
  59.         print("We've got a big'un!")
  60.     end
  61.     treeLoop()
  62. end
  63.  
  64. --Execution Code
  65. if fuelCheck() then
  66.     startup()
  67.     print("Finished! Any key to continue...")
  68.     read()
  69. else
  70.     print("Not enough fuel to continue, please refuel and retry. Any key to continue...")
  71.     read()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment