Arphahat

Harvest v3

Jan 23rd, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. treeSpacing=2
  2. deepCount=9
  3. wideCount=14
  4. minFuel=30
  5. fuelSpot=1
  6. woodSpot=2
  7. saplingSpot=3
  8. fertilizerSpot=4
  9. sapBackup=16
  10.  
  11. function plantTree()
  12.   turtle.select(saplingSpot)
  13.   turtle.placeDown()  
  14.   if turtle.getItemCount(saplingSpot)==0 then
  15.     turtle.select(sapBackup)
  16.     turtle.transferTo(saplingSpot,turtle.getItemCount(sapBackup))
  17.   end
  18.   turtle.select(woodSpot)
  19. end
  20.  
  21. function checkFuel()
  22.   if turtle.getFuelLevel() < minFuel then
  23.     turtle.select(fuelSpot)
  24.     turtle.refuel(1)
  25.   end
  26. end
  27.  
  28. function chopTree()
  29.   turtle.dig()  
  30.   turtle.forward()
  31.   turtle.digDown()
  32.   plantTree()
  33.   while turtle.compareUp() do
  34.     turtle.digUp()
  35.     turtle.up()
  36.   end
  37.   while turtle.down() do end
  38.   turtle.forward()
  39. end
  40.  
  41. function fertilizeTree()
  42.   turtle.down()
  43.   turtle.select(fertilizerSpot)
  44.   turtle.place()
  45.   turtle.select(woodSpot)
  46.   turtle.up()
  47. end
  48.  
  49. function nextColumn(currentColumn)
  50.   if currentColumn % 2 == 1 then
  51.     turtle.turnRight()
  52.     turtle.forward()
  53.     turtle.forward()
  54.     turtle.forward()
  55.     turtle.turnRight()
  56.   else
  57.     turtle.turnLeft()
  58.     turtle.forward()
  59.     turtle.forward()
  60.     turtle.forward()
  61.     turtle.turnLeft()
  62.   end
  63. end
  64.  
  65. function dumpExtra()
  66.   for slot=5,15 do
  67.     turtle.select(slot)
  68.     turtle.drop()
  69.   end
  70. end
  71.  
  72. function dumpLogs()
  73.   dumpExtra()
  74.   turtle.select(woodSpot)
  75.   turtle.drop(turtle.getItemCount(woodSpot)-1)
  76. end
  77.  
  78. function resetToStart()
  79.   turtle.select(fuelSpot)
  80.   turtle.refuel(2)
  81.   turtle.turnRight()
  82.   while turtle.forward() do end
  83.   turtle.select(saplingSpot)
  84.   turtle.suck()
  85.   turtle.select(sapBackup)
  86.   turtle.suck()
  87.   dumpExtra()
  88.   turtle.turnLeft()
  89.   turtle.select(fuelSpot)
  90.   turtle.suck()
  91.   dumpExtra()
  92.   turnAround()
  93. end
  94.  
  95. function turnAround()
  96.   turtle.turnLeft()
  97.   turtle.turnLeft()
  98. end
  99.  
  100. function tryChop()
  101.   if turtle.compare() then
  102.     chopTree()
  103.   else     
  104.     fertilizeTree()    
  105.     if turtle.compare() then
  106.         chopTree()
  107.     else -- if fertilize didn't spawn a tree for some reason, skip this and go to next tree
  108.         turtle.forward()
  109.         turtle.forward()
  110.     end
  111.   end
  112. end
  113.  
  114. --while true do
  115.   checkFuel()
  116.   turtle.up()
  117.   for j=1,wideCount do
  118.     tryChop()
  119.     for i=1,deepCount-1 do
  120.       checkFuel()
  121.       turtle.select(woodSpot)
  122.       for s=1,treeSpacing-1 do
  123.         turtle.forward()
  124.       end
  125.      
  126.       tryChop()
  127.  
  128.     end
  129.    
  130.     if wideCount~=j then
  131.       nextColumn(j)
  132.     end
  133.   end    
  134.   turtle.down()
  135.   dumpLogs()
  136.   resetToStart()  
  137. --end
Advertisement
Add Comment
Please, Sign In to add comment