Advertisement
riking

Untitled

Sep 23rd, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. #####Receiver:
  2. rednet.open(...)
  3.  
  4. function lightsOn()
  5.   rs.setOutput("right", true)
  6. end
  7. function lightsOff()
  8.   rs.setOutput("right", false)
  9. end
  10. function detectSignal()
  11.   event,id,message = os.pullEvent()
  12.   if event == rednet_message and id == 1 then
  13.     if message == "On" then
  14.       lightsOn()
  15.     elseif message == "Off" then
  16.       lightsOff()
  17.     end
  18.   end
  19. end
  20. while true do
  21.   detectSignal()
  22. end
  23.  
  24. #####Sender:
  25. rednet.open(...)
  26.  
  27. while true do
  28.   term.clear()
  29.   term.setCursorPos(1,1)
  30.   print("Would you like to switch the lights on or off?")
  31.   input = read()
  32.   if input=="On" or input=="Off" then
  33.     rednet.send(0, input)
  34.   else
  35.     print("Please use only 'On' and 'Off'.")
  36.   end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement