jcoutie

Tree Line Farm

Jan 26th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. fromHome = 0
  2. finished = false
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. print("Ready to commence simpole tree harvest!")
  6. print()
  7. print("Place wood blocks in Slot 1.")
  8. print("Place saplings in Slot 16.")
  9. print()
  10. print("Press [ENTER] to begin.")
  11. read(input)
  12.  
  13. -- Functions
  14.  
  15. local function fuel()
  16.   if turtle.getFuelLevel() < 1000  then
  17.     turtle.refuel(1)
  18.   end
  19. end
  20.  
  21. local function tMove(distance)
  22.   fuel()
  23.   for i=1,distance do
  24.     while turtle.forward() == false do
  25.       turtle.dig()
  26.       turtle.attack()
  27.       sleep(0.5)
  28.     end
  29.   end
  30. end
  31.  
  32. local function tDescend(distance)
  33.   for i=1,distance do
  34.     while turtle.down() == false do
  35.       turtle.digDown()
  36.       turtle.attackDown()
  37.       sleep(0.5)
  38.     end
  39.   end
  40. end
  41.  
  42. local function tAscend(distance)
  43.   for i=1,distance do
  44.     while turtle.up() == false do
  45.       turtle.digUp()
  46.       turtle.attackUp()
  47.       sleep(0.5)
  48.     end
  49.   end
  50. end
  51.  
  52. local function turnaround()
  53.   turtle.turnRight()
  54.   turtle.turnRight()
  55. end
  56.  
  57. -- Main Loop
  58. while fromHome < 8 do
  59.   tMove(2)
  60.     height = 0
  61.     turtle.select(1)
  62.     tMove(1)
  63.     while turtle.detectUp() == true do
  64.       tAscend(1)
  65.       height = height + 1
  66.     end
  67.     tDescend(height)
  68.     turtle.digDown()
  69.     turtle.select(16)
  70.     turtle.placeDown()
  71.     turtle.select(1)
  72.     fromHome = fromHome + 1
  73.   end
  74.     turtle.turnRight()
  75.     tMove(1)
  76.     turtle.turnRight()
  77.     tMove(3*fromHome)
  78.     turtle.turnRight()
  79.     tMove(1)
  80.     turtle.turnRight()
  81. for i=2,15 do
  82.   turtle.select(i)
  83.   turtle.dropDown()
  84. end
  85. turtle.select(1)
Advertisement
Add Comment
Please, Sign In to add comment