Advertisement
readix

Turbine AlarmDistant

Apr 24th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local alarm  =false
  2. local note1 =peripheral.wrap("right")
  3. local note2 =peripheral.wrap("back")
  4. local wl = peripheral.wrap("top")
  5. wl.open(198)
  6.  
  7.  
  8. function play()
  9.     while true do
  10.         while alarm do
  11.             note1.setPitch(23)
  12.             note2.setPitch(23)
  13.             note1.triggerNote()
  14.             note2.triggerNote()
  15.             sleep(1)
  16.             note1.setPitch(24)
  17.             note2.setPitch(24)
  18.             note1.triggerNote()
  19.             note2.triggerNote()
  20.             sleep(1)
  21.  
  22.         end
  23.         sleep(1)
  24.     end
  25. end
  26.  
  27.  
  28. function receive()
  29.     while true do
  30.         local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  31.         if senderChannel==198 then
  32.             if message=="true" then
  33.                 alarm=true
  34.             elseif message=="false" then
  35.                 alarm=false
  36.             end
  37.         end
  38.         sleep(1)
  39.     end
  40. end
  41.  
  42.  
  43. parallel.waitForAny(receive, play)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement