TehNoiseBomb_

ComputerCraft 1.75 - 9x9 Farming - farm

Apr 13th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. --@Author: Zach Combs aka TehNoiseBomb
  2. --@Version: 1.1
  3.  
  4. local inputs = {...}
  5. local crop, seed, fullyGrown = ... --variables passed in (inputs)
  6.  
  7. local getSeed = assert(loadfile("getSeed")) --Load the getSeed code as a variable that can be called as a function
  8.  
  9. local bool, block = turtle.inspectDown() --turtle.inspectDown() returns a boolean value success and a table containing details of the block below the turtle
  10. local item --A table containing the name, damage and count of an item later selected by the turtle, will be returned to moveLine
  11.  
  12. --Create the table for the seed (see getSeed for more details)
  13. item = getSeed(seed)
  14.  
  15. --If the turtle fails to see a crop (or block) below it:
  16. -- If the item table is not blank:
  17. --  If the amount of the item is more than one:
  18. --   Select the slot the item is in
  19. --   Attempt to plant the item
  20. if not bool then
  21.  if item then
  22.   if item.count > 1 then
  23.    print("Selecting seed... ", turtle.select(seedSlot))
  24.    print("Attempting to plant... ", turtle.placeDown(), "...")
  25.   end
  26.  end
  27. end
  28.  
  29. --If the unlocalized name of the block below the turtle is equal to the passed in crop's:
  30. -- If the crop is fully grown:
  31. --  Harvest
  32. --  If the turtle contains more than one of the crop's seed:
  33. --   Select the seed
  34. --   Plant the seed
  35. if block.name == crop then
  36.  if block.metadata == fullyGrown then
  37.   print("Harvesting... ", turtle.digDown())
  38.   item = getSeed(seed)
  39.   if item.count > 1 then
  40.    print("Selecting seed... ", turtle.select(item.slot))
  41.    print("Planting... ", turtle.placeDown())
  42.   end
  43.  end
  44. end
  45.  
  46. --Return the table item containing the slot, name, count and damage value of the seed
  47. return item
Add Comment
Please, Sign In to add comment