Advertisement
Frekvens1

[OC] [Music] The Legend of Zelda, unlocking secret.

Feb 22nd, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. -- Script created by Frekvens1 --
  2.  
  3. -- OpenComputers --
  4. -- Components required: Computer Case, Redstone I/O, Adapter, Note Block, button --
  5. -- Run script on PC, and give the redstone I/O a redstone signal! --
  6. -- Remember to put the note block next to the adapter --
  7. -- If downloaded from pastebin, internet card too --
  8. -- pastebin get WYjyceBK zelda.lua
  9.  
  10. local component = require("component")
  11. local sides = require("sides")
  12. local term = require("term")
  13.  
  14. local rs = component.redstone
  15. local nb = component.note_block
  16.  
  17. local t = 0.2 -- Delay between each note
  18.  
  19. local check_for_redstone_all_sides = true -- Set to true if only one side of the redstone I/O block should activate the song
  20. local rs_Side = sides.front
  21.  
  22. local zelda_Song = {13,12, 9, 3, 2,10,14,18}
  23. local zelda_Wait = { t, t, t, t, t, t, t}
  24.  
  25. function sleep(duration)
  26.    os.sleep(tonumber(duration))
  27. end
  28.  
  29. function playNote(note, sleep_duration)
  30.     nb.trigger(tonumber(note))
  31.     sleep(sleep_duration)
  32. end
  33.  
  34. function playZelda()
  35.     term.clear()
  36.     print("Now playing:")
  37.     print("The Legend of Zelda, unlocked secret")
  38.  
  39.     for i, note in ipairs(zelda_Song) do
  40.          playNote(note, zelda_Wait[i])
  41.     end
  42.     term.clear()
  43. end
  44.  
  45. while true do
  46.      if (check_for_redstone_all_sides) then
  47.  
  48.          local r_s = rs.getInput
  49.  
  50.          if (r_s(sides.bottom) > 0) then
  51.              playZelda()
  52.          elseif (r_s(sides.top) > 0) then
  53.              playZelda()
  54.          elseif (r_s(sides.back) > 0) then
  55.              playZelda()
  56.          elseif (r_s(sides.front) > 0) then
  57.              playZelda()
  58.          elseif (r_s(sides.right) > 0) then
  59.              playZelda()
  60.          elseif (r_s(sides.left) > 0) then
  61.              playZelda()
  62.          else
  63.              os.sleep(0.1)
  64.          end
  65.  
  66.      else
  67.  
  68.          local rs_Input = rs.getInput(rs_Side)
  69.  
  70.          if (rs_Input > 0) then
  71.              playZelda()
  72.          else
  73.              os.sleep(0.1)
  74.          end
  75.  
  76.      end
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement