Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Automatic Disc Changer API
- -- By David Findley
- -- 2013-04-05 (yyyy-mm-dd)
- -- Lengths of all the vanilla discs.
- -- If you want to use non-vanilla discs
- -- then add the name and length here.
- local lengths = {["C418 - 13"]=180, ["C418 - cat"]=186, ["C418 - blocks"]=347, ["C418 - chirp"]=186, ["C418 - far"]=172, ["C418 - mall"]=197, ["C418 - mellohi"]=98, ["C418 - stal"]=151, ["C418 - strad"]=191, ["C418 - ward"]=250, ["C418 - 11"]=70}
- -- Edit these values depending on your setup.
- -- If you use the setup I posted, then leave them.
- local loadS = "left"
- local ejectS = "back"
- local resetS = "top"
- local diskS = "bottom"
- function reset()
- for i=1,10 do
- rs.setOutput(resetS, true)
- sleep(0.1)
- rs.setOutput(resetS, false)
- sleep(0.1)
- end
- end
- function eject()
- rs.setOutput(ejectS, true)
- sleep(0.1)
- rs.setOutput(ejectS, false)
- end
- -- Loads a disk into the drive.
- -- Returns true if the disk has audio
- function load()
- rs.setOutput(loadS, true)
- sleep(0.1)
- rs.setOutput(loadS, false)
- sleep(0.5)
- if (disk.hasAudio(diskS)) then
- return true
- else
- return false
- end
- end
- -- Plays audio on the disk
- -- Returns the length of the song
- -- in seconds
- function play()
- disk.playAudio(diskS)
- local t = lengths[disk.getAudioTitle(diskS)]
- return t
- end
- -- Stop the music
- function stop()
- disk.stopAudio(diskS)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement