Quetzi

Tree chopper

Feb 9th, 2013
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. local invalid = true
  2. local width
  3. local height = 0
  4.  
  5. repeat
  6.   print( "How many blocks wide is the tree?" )
  7.   width = tonumber(io.read())
  8.   if width < 1 then
  9.     print( "Tree width must be at least 1 block!" )
  10.     invalid = true
  11.   end
  12.   if width > 2 then
  13.     print( "Max width for Tree is 2 blocks" )
  14.     invalid = true
  15.   end
  16.   if (width >=1) and (width <=2) then
  17.     print( "Chopping " .. width .. " wide tree")
  18.     invalid = false
  19.   end
  20. until invalid == false
  21.  
  22. if width == 1 then
  23.   if turtle.detect() then
  24.     turtle.dig()
  25.     turtle.forward()
  26.   end
  27.   while turtle.detectUp() do
  28.     turtle.digUp()
  29.     turtle.up()
  30.     height=height+1
  31.   end
  32.   for i=1,height do
  33.     turtle.down()
  34.   end
  35. end
  36.  
  37. if width == 2 then
  38.   if turtle.detect() then
  39.     turtle.dig()
  40.     turtle.forward()
  41.   end
  42.   while turtle.detect() do
  43.     turtle.dig()
  44.     turtle.turnRight()
  45.     if turtle.detect() then
  46.       turtle.dig()
  47.     end
  48.     turtle.turnLeft()
  49.     if turtle.detectUp() then
  50.       turtle.digUp()
  51.       turtle.up()
  52.       height=height+1
  53.     end
  54.   end
  55.   turtle.forward()
  56.   turtle.turnRight()
  57.   if turtle.detect() then
  58.     turtle.dig()
  59.   end
  60.   turtle.forward()
  61.   turtle.turnLeft()
  62.   for i=1,height do
  63.     turtle.digDown()
  64.     turtle.down()
  65.   end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment