legg0028

secret_door_open

Aug 3rd, 2021 (edited)
297
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local modem = peripheral.wrap("back")
  2. modem.open(00005)
  3.  
  4. local status = 1
  5.  
  6. redstone.setOutput("top",false)
  7. redstone.setOutput("bottom",false)
  8.  
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. print("Waiting on message")
  12.  
  13. while true do
  14.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  15.  
  16.     term.clear()
  17.     term.setCursorPos(1,1)
  18.     print("Message received: "..message)
  19.     print("Channel: "..senderChannel)
  20.  
  21.     if senderChannel == 5 and message == "open" and status == 1 then
  22.         redstone.setOutput("bottom",true)
  23.         redstone.setOutput("top",true)
  24.         status = 2
  25.     elseif senderChannel == 5 and message == "open" and status == 2 then
  26.         redstone.setOutput("bottom",false)
  27.         redstone.setOutput("top",false)
  28.         status = 1
  29.     end
  30.     sleep(0.1)
  31. end
RAW Paste Data