TehNoiseBomb_

ComputerCraft 1.75 - 9x9 Farming - farm9x9

Apr 13th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. --@Author: Zach Combs aka TehNoiseBomb
  2. --@Version: 1.4
  3.  
  4. local inputs = {...}
  5. local crop, seed, fullyGrown, sleepTime = ... --variables passed in (inputs)
  6.  
  7. local moveLine = assert(loadfile("moveLine")) --Load the moveLine code as a variable that can be called as a function
  8. local nextRow = assert(loadfile("nextRow")) --Load the nextRow code as a variable that can be called as a function
  9. local moveHome = assert(loadfile("moveHome")) --Load the moveHome code as a variable that can be called as a function
  10. local getSeed = assert(loadfile("getSeed")) --Load the getSeed code as a variable that can be called as a function
  11. local itemDump = assert(loadfile("itemDump")) --Load the itemDump code as a variable that can be called as a function
  12. local refuel = assert(loadfile("refuel")) --Load the refuel code as a variable that can be called as a function
  13.  
  14. local east = true --boolean flag determining if the turtle is facing east(true) or west(false) -> You can check in F3 mode, when placed the turtle is facing the same way as the player
  15. local seedData = getSeed(seed) --Get the data about the seed in the turtle's inventory
  16. local fuelLevel = turtle.getFuelLevel() --Get the amount of fuel the turtle has
  17.  
  18. print("Working on crop: ", crop)
  19. print("Working with seed: ", seed)
  20.  
  21. --While the turtle has fuel, repeat the following steps:
  22. -- Print the amount of fuel the turtle has
  23. -- Reset the turning flag to true
  24. -- Get how much fuel the turtle has
  25. -- If the turtle has seeds in it's inventory:
  26. --  Move through the first row and get how many seeds the turtle has in it's inventory
  27. --  Starting in the first row, repeat eight times:
  28. --   Move to the next row on the right and get set the new orientation to the east slag
  29. --   Move through the row and get how many seeds the turtle has in it's inventory
  30. --  Move to the home position
  31. --  Move to the chest, dump excess inventory and transfer the seeds to the first slot in the turtle's inventory
  32. --  Move to the fuel chest and refuel
  33. --  Get how much fuel the turtle has
  34. -- Sleep for the passed in amount of time
  35. while fuelLevel > 0 do
  36.  print("Fuel left... ", fuelLevel)
  37.  east = true
  38.  fuelLevel = turtle.getFuelLevel()
  39.  if seedData.count > 0 then
  40.   seedData = moveLine(crop, seed, fullyGrown)
  41.   for i = 0, 7 do
  42.    east = nextRow(east)
  43.    seedData = moveLine(crop, seed, fullyGrown)
  44.   end
  45.   moveHome()
  46.   seedData = itemDump(seedData)
  47.   fuelLevel = refuel(fuelLevel)
  48.  end
  49.  os.sleep(sleepTime)
  50. end
Add Comment
Please, Sign In to add comment