SHARE
TWEET

farmScript

a guest Apr 23rd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Robot modules,functions,variables
  2. ---------------------------------------------------------------
  3. local component = require("component")
  4. local robot = require("robot")
  5. local sides = require("sides")
  6.  
  7. local geolyzer = component.proxy(component.get("935"))
  8.  
  9. local x = 7 --deep
  10. local y = 10 --wide
  11. local facing = "forward"
  12. local temp = "place holder"
  13.  
  14. function harvestRows(s)
  15.   for i=1,s-1 do --deep loop
  16.    -- robot.placeDown() --plants crop below robot
  17.   --  robot.forward(1)
  18.  
  19.     local scan = geolyzer.analyze(sides.down) --scans metadata of block below to see if it's ready for harvest
  20.       for k,v in pairs(scan) do        
  21.         if scan.metadata == 3 then
  22.           robot.swingDown() --harvests plant
  23.         end
  24.       end
  25.     robot.placeDown()
  26.     robot.forward()
  27.   end
  28. end
  29.  
  30. function nextRow(s)
  31.   if s == "forward" then
  32.     robot.turnRight()
  33.     harvestRows(2)
  34.    -- robot.forward(1)
  35.    -- harvestRows(1)
  36.     robot.turnRight()
  37.     temp = "back"
  38.   end
  39.   if s == "back" then
  40.     robot.turnLeft()
  41.     harvestRows(2)
  42.     robot.turnLeft()
  43.     temp = "forward"
  44.   end
  45.   facing = temp
  46. end
  47.  
  48. function toStart(s)
  49.   if s == "forward" then
  50.     robot.turnLeft()
  51.     for i=1,y do robot.forward(1) end
  52.     robot.turnRight()
  53.   end
  54.   if s == "back" then
  55.    for i=1,x-1 do robot.forward(1) end
  56.     robot.turnRight()
  57.    for i=1,y do robot.forward(1) end
  58.     robot.turnRight()
  59.   end
  60. end
  61. ------------------------------------------------------------------------------------------  
  62. --Robot program
  63. -----------------------------------------------------------------------------------------
  64. for i=1,y do           --for the width of the farm
  65.   harvestRows(x)        --harvest a row x deep
  66.   nextRow(facing)      --move to the next row and turn around
  67. end
  68.  
  69. toStart(facing)        --return robot to start
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top