Advertisement
ArsKvsh

[CC] metro arrival

Jan 25th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. inst = 'flute'
  2. spd = 2.5
  3. octave = 0
  4. i = 0
  5.  
  6. local run = false
  7.  
  8. local speaker = {}
  9. speaker = {peripheral.find("speaker")}
  10.  
  11. function speakAll (pitch)
  12.     for i=1, #speaker do
  13.         speaker[i].playNote(inst, 3, pitch + octave)
  14.     end
  15. end
  16.  
  17. function alarm ()
  18.     run = true
  19.     speakAll(0)
  20.     sleep(0.25 * spd)
  21.     speakAll(4)
  22.     sleep(0.25 * spd)
  23.     speakAll(7)
  24.     sleep(0.25 * spd)
  25.     speakAll(12)
  26.     run = false
  27. end
  28.  
  29. while true do
  30.   os.pullEvent("redstone")
  31.   if (rs.getInput("bottom") and not run) then
  32.      alarm ()
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement