Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = 1.4
- local filename = "music"
- local paste = "CSEcjQ7n"
- local curTimer = nil
- local playing = false
- local function update()
- local url = "http://pastebin.com/raw.php?i="..paste
- local temp = http.get(url)
- local ver = temp.readLine()
- if tonumber(string.sub(ver, 17)) ~= version then
- fs.delete(filename)
- shell.run("pastebin get "..paste.." "..filename)
- shell.run(filename)
- return true
- end
- return false
- end
- local test = update()
- if test == true then
- error()
- end
- rednet.open("top")
- local times = {}
- times.blocks = 345
- times.far = 174
- times.mall = 197
- times.strad = 188
- times.wait = 238
- local songs = {"blocks", "far", "mall", "strad", "wait"}
- local CurrentSong = 0
- local function clearSong()
- term.setCursorPos(2,5)
- write(" ")
- end
- local function writeSong()
- clearSong()
- term.setCursorPos(17,5)
- write("-"..songs[CurrentSong].."-")
- end
- local function pasteScreen()
- shell.run("clear")
- print("version: "..version)
- print("+----------~Computercraft Music Player~----------+")
- print("| |")
- print("| Current Song: |")
- print("| |")
- print("| |")
- print("| <-Previous >Play Next-> |")
- print("| |")
- print("+------------------------------------------------+")
- end
- local function previousSong()
- if CurrentSong == 1 or CurrentSong == 0 then
- CurrentSong = 5
- else
- CurrentSong = CurrentSong - 1
- end
- writeSong()
- rednet.broadcast(songs[CurrentSong])
- curTimer = os.startTimer(times[songs[CurrentSong]])
- end
- local function nextSong()
- if CurrentSong == 5 or CurrentSong == 0 then
- CurrentSong = 1
- else
- CurrentSong = CurrentSong + 1
- end
- writeSong()
- rednet.broadcast(songs[CurrentSong])
- curTimer = os.startTimer(times[songs[CurrentSong]])
- end
- local function togglePlay()
- if CurrentSong == 0 then
- CurrentSong = 1
- end
- writeSong()
- rednet.broadcast(songs[CurrentSong])
- curTimer = os.startTimer(times[songs[CurrentSong]])
- end
- pasteScreen()
- while true do
- local e, p1, x, y = os.pullEvent()
- if e == "mouse_click" then
- if y == 7 then
- if x >= 9 and x <= 18 then
- previousSong()
- elseif x >= 25 and x <= 29 then
- togglePlay()
- elseif x >= 37 and x <= 42 then
- nextSong()
- end
- end
- end
- if e == "timer" and p1 == curTimer then
- nextSong()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement