Advertisement
Guest User

harvest2

a guest
Oct 19th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.42 KB | None | 0 0
  1. local left = 11  -- Blue Wool
  2. local right = 14 -- Read Wool
  3. local turnBack = 7 -- Grey Wool
  4.  
  5. local pkLoc = 1
  6. local wheatLoc = 1
  7. local seedLoc = 1
  8. local carrotLoc = 1
  9. local sugurLoc = 1
  10.  
  11. local cropSeeds = "minecraft:wheat_seeds"
  12. local cropSugar = "minecraft:reeds"
  13. local cropPk = "minecraft:pumpkin"
  14. local cropWheat = "minecraft:wheat"
  15. local cropCarrot = "minecraft:carrot"
  16. local cropPotato = "minecraft:potato"
  17. local currentCrop = cropWheat
  18.  
  19. local bChest = "minecraft:chest"
  20.  
  21. function setLocs()
  22.   for i=1,16 do
  23.     turtle.select(i)
  24.     if turtle.getItemCount(i) > 0 then
  25.       data = turtle.getItemDetail(i)            
  26.       if data.name == cropSeeds then
  27.         seedLoc = i
  28.         print("seedLoc = ",seedLoc)
  29.       elseif data.name == cropPk then
  30.         pkLoc = i              
  31.         print("pumpkins =",pkLoc)
  32.       elseif data.name == cropCarrot then
  33.         carrotLoc = i
  34.         print("carrots = ",carrotLoc)
  35.       elseif data.name == cropPotato then
  36.         potatoLoc = i
  37.         print("potatos = ",potatoLoc)  
  38.       elseif data.name == cropSugar then
  39.         sugarLoc = i
  40.         print("SugarCane =", sugarLoc)    
  41.       elseif data.name == cropWheat then
  42.         wheatLoc = i
  43.         print("Wheat =", wheatLoc)
  44.       end        
  45.     end
  46.   end
  47. end
  48.  
  49. function refuel()
  50.   for i = 1, 16 do
  51.     turtle.select(i)
  52.     if turtle.getItemCount(i) >0 then
  53.       turtle.refuel()      
  54.     end
  55.   end
  56.   print("Fuel Level", turtle.getFuelLevel())
  57. end
  58.  
  59. setLocs()
  60. currentSeed = seedLoc
  61.  
  62. while true do
  63.   refuel()
  64.   while turtle.getFuelLevel() > 0 do  
  65.     local succFront, IDFront = turtle.inspect()
  66.     local succDown, IDDown = turtle.inspectDown()
  67.    
  68.     if succDown == false then    
  69.       print("Plant Seed")
  70.       turtle.digDown()  
  71.       if currentSeed == cropPk then
  72.       elseif currentSeed == cropSugar then
  73.       else
  74.         turtle.select(currentSeed)
  75.         turtle.placeDown()
  76.       end
  77.     else
  78.       if IDDown.name == cropWheat then
  79.         if IDDown.metadata == 7 then
  80.           currentCrop = cropWheat
  81.           currentSeed = seedLoc        
  82.           turtle.select(wheatLoc)
  83.           turtle.digDown()      
  84.           turtle.digDown()
  85.           turtle.select(seedLoc)
  86.           turtle.placeDown()        
  87.         end
  88.       elseif IDDown.name == cropCarrot then
  89.         if IDDown.metadata == 7 then
  90.           currentCrop = cropCarrot
  91.           currentSeed = carrotLoc
  92.           turtle.select(carrotLoc)
  93.           turtle.digDown()
  94.           turtle.digDown()
  95.           turtle.placeDown()
  96.         end      
  97.       elseif IDDown.name == cropPk then
  98.         if IDDown.metadata == 0 then
  99.           currentCrop = cropPk          
  100.           turtle.select(pkLoc)
  101.           turtle.digDown()
  102.         end
  103.       elseif IDDown.name == bChest then        
  104.         for i = 1, 8, 1 do
  105.            turtle.select(i)
  106.            turtle.dropDown(turtle.getItemCount(i))
  107.         end  
  108.       end    
  109.     end  
  110.    
  111.     if IDFront.name ==  "minecraft:wool" then    
  112.       if IDFront.metadata == left then
  113.         turtle.turnLeft()
  114.       elseif IDFront.metadata == right then
  115.         turtle.turnRight()
  116.       elseif IDFront.metadata == turnBack then            
  117.         turtle.turnLeft()
  118.         turtle.turnLeft()
  119.       end
  120.     elseif IDFront.name == "minecraft:reeds" then
  121.       currentCrop = cropSugar
  122.       turtle.dig()  
  123.     end
  124.       turtle.forward()  
  125.   end
  126.  
  127.   setLocs()
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement