Advertisement
CdoubleOK

Ref switch control 2

May 2nd, 2023 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local modem = peripheral.find("modem")
  2. local outputMap = {
  3.   [6] = "left",
  4.   [7] = "right",
  5.   [8] = "front",
  6.   [9] = "back",
  7.   [10] = "bottom"
  8. }
  9.  
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. print("Running")
  13.  
  14. while rs.getInput("front") == false do
  15.   modem.open(27)
  16.   local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  17.   modem.close(27)
  18.  
  19.   if outputMap[replyChannel] and message == "On" then
  20.     rs.setOutput(outputMap[replyChannel], true)
  21.   end
  22.    
  23.   if outputMap[replyChannel] and message == "Off" then
  24.     rs.setOutput(outputMap[replyChannel], false)
  25.   end
  26.    
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement