Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- playAPIDemo by James0x57 using Noteblock Studio file (.nbs) player for MiscPeripherals (a ComputerCraft mod)
- -- You are free to copy, alter, and distribute this under the following conditions:
- -- 1) You leave these comments and credits attached
- -- 2) You do not make money off of this
- -- Program by James0x57 - http://www.youtube.com/watch?v=ro4EK8smULQ
- -- Noteblock Studio by _Davve_ - http://www.minecraftforum.net/topic/136749-minecraft-note-block-studio-150000-downloads/
- -- MiscPeripherals by RichardG867 - http://www.computercraft.info/forums2/index.php?/topic/4587-cc1481mc146-miscperipherals-23/
- -- ComputerCraft by Dan - http://www.computercraft.info/
- -- 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!! =)
- os.loadAPI("play");
- function nowPlaying(song)
- term.clear();
- print("Now Playing: \n\n\n\n\n\n " .. song.name);
- print("\n\n\n\n\n\nAuthor: " .. song.author);
- print("Original Author: " .. song.originalAuthor);
- print("Description: ");
- print(song.description);
- end
- function playRandomSongWhileRedstone()
- play.clearMenu();
- play.loadMenu("songs");
- while play.changeRepeatMode() ~= "None" do end -- when redstone is turned on, play just one random song
- -- -----------------------------------------------------------------------------------------------
- -- If you want this to keep playing songs while redstone is on, remove "--" from the next line
- -- while play.changeRepeatMode() ~= "All (Random)" do end
- -- -----------------------------------------------------------------------------------------------
- local event = "redstone";
- local rsState = not redstone.getInput('right');
- while true do
- if event == "redstone" and rsState ~= redstone.getInput('right') then
- rsState = not rsState;
- if not rsState then
- play.stopSong();
- term.clear();
- print("Waiting for redstone signal on right...");
- elseif rsState then
- play.menuAt(math.random(#play.menuTable()));
- end
- elseif event == "playStarted" then
- nowPlaying(play.current());
- end
- event = os.pullEvent();
- end
- end
- parallel.waitForAll(play.playNotes, playRandomSongWhileRedstone);
Add Comment
Please, Sign In to add comment