Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. -- HobNet Host --
  2.  
  3. -- Startup
  4.  
  5. protocol = "HobNet";
  6. hostName = "Master";
  7. port = "right";
  8. waitTime = 10
  9.  
  10. rednet.open("right");
  11. rednet.host(protocol, hostName);
  12.  
  13. oilrigId = 0
  14.  
  15. print("Loading...")
  16.  
  17. function Oilrig()
  18. print("Oilrig:")
  19. command = rednet.receive(protocol) -- waitTime
  20.  
  21. if(command == "Motor1 On") then
  22. print("Motor #1 is now: On")
  23. rednet.send(oilrigId, "Motor1 On", protocol)
  24.  
  25. elseif(command == "Motor1 Off") then
  26. print("Motor #1 is now: Off")
  27. rednet.send(oilrigId, "Motor1 Off", protocol)
  28. end
  29.  
  30.  
  31. end
  32.  
  33. function Shutdown()
  34. rednet.unhost(protocol, hostName)
  35. rednet.close(port)
  36. end
  37.  
  38.  
  39.  
  40. print("Done entering main loop...")
  41.  
  42. while true do
  43. print("Waiting for input...")
  44. input = rednet.receive(protocol)
  45. if(input[2] == "Oilrig") then
  46. Oilrig()
  47. end
  48.  
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement