Advertisement
Faited

Reception - ComputerCraft

Nov 27th, 2022 (edited)
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function Pulse()
  2.   redstone.setOutput("back", not redstone.getOutput("back"))
  3. end
  4.  
  5. local function Pulse2()
  6.     redstone.setOutput("right", not redstone.getOutput("right"))
  7. end
  8.  
  9. function bool_to_number(value)
  10.   return value and 1 or 0
  11. end
  12.  
  13. local modem = peripheral.find("modem")
  14. local event, side, channel, replyChannel, message, distance
  15.  
  16. modem.open(43)
  17.  
  18. while true do
  19.     event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  20.     if message == "swap" then
  21.         Pulse()
  22.         modem.transmit(replyChannel, 43, redstone.getOutput("back"))
  23.     end
  24.     if message == "stop" then
  25.         Pulse2()
  26.         modem.transmit(replyChannel, 43, bool_to_number(redstone.getOutput("right")) + 2)
  27.     end
  28.     print(message)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement