GRxRedZero

Untitled

Apr 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. -- playAPIDemo by James0x57 using Noteblock Studio file (.nbs) player for MiscPeripherals (a ComputerCraft mod)
  2. -- You are free to copy, alter, and distribute this under the following conditions:
  3. -- 1) You leave these comments and credits attached
  4. -- 2) You do not make money off of this
  5. -- Program by James0x57 - http://www.youtube.com/watch?v=ro4EK8smULQ
  6. -- Noteblock Studio by _Davve_ - http://www.minecraftforum.net/topic/136749-minecraft-note-block-studio-150000-downloads/
  7. -- MiscPeripherals by RichardG867 - http://www.computercraft.info/forums2/index.php?/topic/4587-cc1481mc146-miscperipherals-23/
  8. -- ComputerCraft by Dan - http://www.computercraft.info/
  9. -- If you use this in anything you create, please show credit where due, and let me know because I'd love to see it used!! =)
  10.  
  11. os.loadAPI("play");
  12.  
  13. function nowPlaying(song)
  14. term.clear();
  15. print("Now Playing: \n\n\n\n\n\n " .. song.name);
  16. print("\n\n\n\n\n\nAuthor: " .. song.author);
  17. print("Original Author: " .. song.originalAuthor);
  18. print("Description: ");
  19. print(song.description);
  20. end
  21.  
  22. function playRandomSongWhileRedstone()
  23. play.clearMenu();
  24. play.loadMenu("songs");
  25.  
  26. while play.changeRepeatMode() ~= "None" do end -- when redstone is turned on, play just one random song
  27.  
  28. -- -----------------------------------------------------------------------------------------------
  29. -- If you want this to keep playing songs while redstone is on, remove "--" from the next line
  30. -- while play.changeRepeatMode() ~= "All (Random)" do end
  31. -- -----------------------------------------------------------------------------------------------
  32.  
  33. local event = "redstone";
  34. local rsState = not redstone.getInput('right');
  35. while true do
  36. if event == "redstone" and rsState ~= redstone.getInput('right') then
  37. rsState = not rsState;
  38. if not rsState then
  39. play.stopSong();
  40. term.clear();
  41. print("Waiting for redstone signal on right...");
  42. elseif rsState then
  43. play.menuAt(math.random(#play.menuTable()));
  44. end
  45. elseif event == "playStarted" then
  46. nowPlaying(play.current());
  47. end
  48. event = os.pullEvent();
  49. end
  50. end
  51.  
  52. parallel.waitForAll(play.playNotes, playRandomSongWhileRedstone);
Add Comment
Please, Sign In to add comment