Advertisement
LDDestroier

CC Wireless Redstone

May 5th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. rid = 1
  2.  
  3. input = "front"
  4. output = "back"
  5.  
  6. local state = false
  7. local modem = peripheral.find("modem")
  8. modem.open(188)
  9.  
  10. local transmit = function()
  11.     modem.transmit(188,188,{id = rid, state = state})
  12. end
  13.  
  14. while true do
  15.     local evt = {os.pullEvent()}
  16.     if evt[1] == "redstone" then
  17.         state = rs.getInput(input)
  18.         transmit()
  19.     elseif evt[1] == "modem_message" then
  20.         local msg = evt[5]
  21.         if type(msg) == "table" then
  22.             if type(msg.id) == "number" and type(msg.state) == "boolean" then
  23.                 if msg.id == rid then
  24.                     rs.setOutput(output,msg.state)
  25.                 end
  26.             end
  27.         end
  28.     end
  29. end
  30.  
  31. --pastebin get sLkBMb4e wr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement