Advertisement
Guest User

redwood

a guest
Oct 7th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. function needFuel()
  2.   if turtle.getFuelLevel() <= 230 then
  3.     turtle.select(2)
  4.     turtle.refuel(1)
  5.   end
  6. end
  7.  
  8. function digTop()
  9.   while turtle.detect() do
  10.     turtle.digUp()
  11.     turtle.dig()
  12.     turtle.up()
  13.     needFuel()
  14.   end
  15.   while not turtle.detectDown() do
  16.     turtle.down()
  17.   end
  18.   turtle.forward()
  19. end
  20.  
  21. function nextLeft()
  22.   turtle.forward()
  23.   turtle.forward()
  24.   turtle.turnLeft()
  25.   turtle.dig()
  26.   turtle.forward()
  27.   turtle.turnLeft()
  28.   turtle.forward()
  29.   turtle.forward()
  30.   turtle.forward()
  31.   end
  32.  
  33. function nextRight()
  34.   turtle.forward()
  35.   turtle.forward()
  36.   turtle.turnRight()
  37.   turtle.dig()
  38.   turtle.forward()
  39.   turtle.turnRight()
  40.   turtle.forward()
  41.   turtle.forward()
  42.   turtle.forward()
  43. end
  44.  
  45. function mailHome()
  46.   if turtle.getItemCount(3) ~= 0 then
  47.   turtle.dig()
  48.   turtle.select(1)
  49.   turtle.place()
  50.   end
  51.   for i = 3,16 do
  52.     turtle.select(i)
  53.     turtle.drop()
  54.   end
  55.   turtle.select(1)
  56.   turtle.dig()
  57. end
  58.  
  59. function upBack()
  60.   while turtle.detect() do
  61.     digTop()
  62.   end  
  63.   mailHome()
  64.   nextLeft()
  65.   while turtle.detect() do
  66.     digTop()
  67.   end
  68.   mailHome()
  69.   nextRight()
  70. end
  71.  
  72. local tree = ""
  73.   print("Lets cut down some trees!")
  74.   print("Slot 1 - Ender Chest")
  75.   print("Slot 2 - Fuel")
  76.  
  77.   write("Tree width? ")
  78.   tree = read()
  79.   loops = (tree+1)/2
  80.   print("Okay, tree width is"..tree)
  81.   print("Times I will loop: "..loops)
  82.   print("This tree is coming down, you may want to back up...")
  83.     for i2 = 1,loops do
  84.         upBack()
  85.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement