Advertisement
Guest User

farm.lua

a guest
Dec 11th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local component=require("component")
  2. local robot=require("robot")
  3. local event=require("event")
  4. local modem=component.proxy(component.modem.address)
  5. local farmRunning=true
  6. local function modemListener(evt,_,_,_,_,msg)
  7.   print("Message Rec")
  8.   print(msg)
  9.   farmRunning=false
  10.   return false
  11. end
  12. local function harvest()  
  13.   for i=1,5 do
  14.     robot.forward()
  15.     robot.useDown()
  16.   end
  17. end
  18. local function harvestHemp()
  19.   for i=1,5 do
  20.     robot.forward()
  21.     robot.swingDown()
  22.     robot.suckDown()
  23.   end
  24. end
  25. local function positionHarvest()
  26.   for i=1,2 do
  27.     robot.forward()
  28.     robot.turnRight()
  29.   end
  30. end
  31. local function dropHarvest()
  32.   for i=1,3 do
  33.     robot.select(i)
  34.     robot.dropDown()  
  35.   end
  36.   robot.select(1)
  37. end
  38. local function repos()
  39.   robot.turnRight()
  40.   robot.forward()
  41.   robot.turnRight()
  42. end
  43. modem.open(20202)
  44. event.listen("modem_message",modemListener)
  45. while farmRunning do
  46.   harvest()
  47.   positionHarvest()
  48.   robot.up()
  49.   harvestHemp()
  50.   robot.forward()
  51.   robot.down()
  52.   dropHarvest()
  53.   repos()
  54.   os.sleep(0.1)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement