Advertisement
Pirnogion

FellingTurtle

Oct 30th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. local line = 0
  2. local active = false
  3.  
  4. local function Info(str, cls)
  5.  if (cls) then
  6.   term.clear()
  7.   term.setCursorPos(1, 1)
  8.  end
  9.  
  10.  print(str)
  11. end
  12.  
  13. local function Refuel()
  14.  if (turtle.getFuelLevel() == 0) then
  15.   local sl = 1
  16.  
  17.   turtle.select(16)
  18.  
  19.   Info("Exepted refueling...", true)
  20.  
  21.   while (not turtle.refuel(1)) do sleep(1) end
  22.  
  23.   Info("Refueling is complete!", false)      
  24.   turtle.select(sl)
  25.  end
  26. end
  27.  
  28. local function Init()
  29.  Info("Need wood block!", true)
  30.  while (turtle.getItemCount(1) == 0) do sleep(1) end
  31.  
  32.  Refuel()
  33.  turtle.dig()
  34.  turtle.suck()
  35.  turtle.forward()
  36.  
  37.  active = true
  38. end
  39.  
  40. Init()
  41.  
  42. while active do
  43.  Refuel()
  44.  
  45.  if (turtle.compare()) then
  46.   turtle.dig()
  47.   turtle.suck()
  48.  
  49.   if (line % 2 == 0) then
  50.    turtle.digUp()
  51.    turtle.suckUp()
  52.    turtle.up()
  53.   else
  54.    turtle.digDown()
  55.    turtle.suckDown()
  56.    turtle.down()
  57.   end
  58.  else
  59.   line = line + 1
  60.  
  61.   if (line == 1) then
  62.    turtle.dig()
  63.    turtle.suck()
  64.    turtle.forward()
  65.    turtle.turnRight()
  66.    turtle.dig()
  67.    turtle.suck()
  68.    turtle.forward()
  69.    turtle.turnRight()
  70.    turtle.dig()
  71.    turtle.suck()
  72.    turtle.digDown()
  73.    turtle.suckDown()
  74.    turtle.down()
  75.   elseif (line == 2) then
  76.    turtle.up()
  77.    turtle.forward()
  78.    turtle.forward()
  79.  
  80.    Info("Felling the tree is complete.", true)  
  81.    active = false
  82.  
  83.   end
  84.  end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement