Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Todo
- -- - Finish writing and testing jukebox!
- -- my libraries
- -- check dir exists, if not make it
- if not fs.exists("/libs") then--{{{
- fs.makeDir("/libs")
- end--}}}
- function update_lib(pastebin_id, dest_path)--{{{
- if fs.exists(dest_path) then
- fs.delete(dest_path)
- end
- shell.run("pastebin get " .. pastebin_id .. " " .. dest_path)
- os.loadAPI(dest_path)
- end--}}}
- --update_lib("qUpykFN4", "libs/ccmisc")
- --update_lib("n1S2GpfD", "libs/sorterAPI")
- os.loadAPI("/libs/sorterAPI")
- -- clear library spam
- --term.setCursorPos(1,1)
- --term.clear()
- -- end my libraries
- Track = {
- title = nil,
- length = nil,
- uuid = nil,
- }
- Jukebox = {
- sorter = peripheral.wrap("interactiveSorter_1"),
- drive = peripheral.wrap("drive_0"),
- chestSide = 1,
- driveSide = 0,
- tracks = {},
- tracksName = {},
- tracksUUID = {},
- }
- function Jukebox:getTracksAvailable()
- local chestTracks = self.sorter.list(self.chestSide)
- local driveTracks = self.sorter.list(self.driveSide)
- print(textutils.serialize(chestTracks))
- --for uuid,count in pairs(chestTracks) do
- -- if tracksUUID[uuid] = nil then
- -- local track = Track
- -- track.uuid = uuid
- -- -- find track name
- -- track.name =
- -- --
- -- tracksUUID[uuid] = track
- -- end
- --end
- end
- function Jukebox:identifyTrack(uuid)
- end
- function Jukebox:findTrackLength(uuid)
- -- load the track
- -- set 1 second timer and play the track
- -- if trackTime event then is track still playing?
- -- if true then increment track length by 1 second and start another 1 second timer.
- -- else don't start a new timer and stop finding track length.
- end
- function Jukebox:loadDisk(wanted_uuid)
- if self.drive.isDiskPresent() then
- -- remove disk
- for uuid, count in pairs(self.sorter.list(self.driveSide)) do
- self.sorter.extract(self.driveSide, uuid, self.chestSide, count)
- end
- end
- -- load requested disk
- self.sorter.extract(self.chestSide, wanted_uuid, self.driveSide, 1)
- end
- function Jukebox:playing()
- -- is the jukebox playing something?
- return self.playing
- end
- function Jukebox:play(track)
- if track == nil then
- self:randomTrack()
- end
- if self.drive.isDiskPresent() then
- if self.drive.hasAudio() then
- self.drive.playAudio()
- end
- end
- self.playing = true
- end
- function Jukebox:randomTrack()
- end
- function Jukebox:stop()
- self.drive.stopAudio()
- end
- function Jukebox:nextTrack()
- end
- function Jukebox:previousTrack()
- end
- function Jukebox:currentTrack()
- if self.drive.isDiskPresent() and self.drive.hasAudio() then
- return self.drive.getAudioTitle()
- else
- return nil
- end
- end
- --jukebox = Jukebox
- --jukebox:getTracksAvailable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement