Advertisement
osmarks

remote_button

Apr 28th, 2020
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. local channel = settings.get "channel" or 0xbee
  2. local name = settings.get "name" or os.getComputerLabel() or error "name needed"
  3. local side = settings.get "side" or error "side needed"
  4. local modem = peripheral.find "modem"
  5.  
  6. modem.open(channel)
  7.  
  8. while true do
  9.     local _, _, c, rc, msg = os.pullEvent "modem_message"
  10.     if type(msg) == "table" and msg[1] == "toggle" and msg[2] == name then
  11.         print "toggle"
  12.         rs.setOutput(side, true)
  13.         sleep(0.1)
  14.         rs.setOutput(side, false)
  15.         modem.transmit(channel, rc, {"toggled", name})
  16.     end
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement