Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitorSide="back"
- local diskDriveSide = "front"
- local ejectRedstoneSide = "left"
- local recordRedSide = "bottom"
- function playRecord(diskDriveSide,recordRedSide,discName)
- if disk.isPresent(diskDriveSide) == true then
- eject(ejectRedstoneSide)
- end
- h = fs.open("music-colors","r")
- line = tostring(h.readLine())
- action = nil
- while line ~= nil do
- value1,discColor = string.match(line,"(.+)%s?:%s?(.+)")
- if string.lower(value1) == string.lower(discName) then
- print("You want to play "..value1)
- print("It is on the "..discColor.." line")
- if string.lower(discColor) == "white" then theColor=1
- elseif string.lower(discColor) == "orange" then theColor=2
- elseif string.lower(discColor) == "magenta" then theColor=4
- elseif string.lower(discColor) == "lightblue" then theColor=8
- elseif string.lower(discColor) == "yellow" then theColor=16
- elseif string.lower(discColor) == "lime" then theColor=32
- elseif string.lower(discColor) == "pink" then theColor=64
- elseif string.lower(discColor) == "gray" then theColor=128
- elseif string.lower(discColor) == "lightgray" then theColor=256
- elseif string.lower(discColor) == "cyan" then theColor=512
- elseif string.lower(discColor) == "purple" then theColor=1024
- elseif string.lower(discColor) == "blue" then theColor=2048
- elseif string.lower(discColor) == "brown" then theColor=4096
- elseif string.lower(discColor) == "green" then theColor=8192
- elseif string.lower(discColor) == "red" then theColor=16384
- elseif string.lower(discColor) == "black" then theColor=32768
- else print("Error: color out of range") return
- end
- print("loading track")
- redstone.setBundledOutput(recordRedSide, theColor)
- sleep(1)
- redstone.setBundledOutput(recordRedSide, 0)
- while not disk.isPresent(diskDriveSide) do
- sleep(.5)
- end
- print("track loaded, playing track")
- disk.playAudio(diskDriveSide)
- end
- line = h.readLine()
- end
- end
- function playButton(diskDriveSide)
- if disk.isPresent(diskDriveSide) ~= true then
- setAction(monitorSide," No disc loaded ")
- sleep(.5)
- else
- print("playing track")
- setAction(monitorSide," Playing disc... ")
- sleep(.5)
- disk.playAudio(diskDriveSide)
- end
- end
- function stop(diskDriveSide)
- print("stopping track")
- disk.stopAudio(diskDriveSide)
- end
- function eject(ejectRedstoneSide)
- print("ejecting track")
- redstone.setOutput(ejectRedstoneSide, true)
- sleep(1)
- redstone.setOutput(ejectRedstoneSide, false)
- end
- function setAction(pSide,message)
- m = peripheral.wrap(pSide)
- m.setCursorPos(14,6)
- m.setBackgroundColor(colors.orange)
- m.write(" ")
- m.setCursorPos(14,7)
- m.write(" ")
- m.setCursorPos(14,8)
- m.write(" ")
- m.setCursorPos(14,9)
- m.write(" ")
- m.setCursorPos(14,10)
- m.write(" ")
- m.setCursorPos(14,11)
- m.write(" ")
- m.setCursorPos(14,12)
- m.write(" ")
- m.setCursorPos(14,13)
- m.write(" ")
- m.setCursorPos(14,14)
- m.write(" ")
- m.setCursorPos(14,10)
- m.setTextColor(colors.black)
- m.write(message)
- m.setBackgroundColor(colors.black)
- end
- function setGUI(pSide)
- m = peripheral.wrap(pSide)
- m.clear()
- m.setCursorPos(18,1)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.blue)
- m.write("RAC Music Player")
- m.setCursorPos(3,3)
- if disk.getLabel(diskDriveSide) =="C418 - cat" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,4)
- if disk.getLabel(diskDriveSide) =="C418 - cat" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Cat ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,5)
- if disk.getLabel(diskDriveSide) =="C418 - cat" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,3)
- if disk.getLabel(diskDriveSide) =="C418 - 13" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,4)
- if disk.getLabel(diskDriveSide) =="C418 - 13" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" 13 ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,5)
- if disk.getLabel(diskDriveSide) =="C418 - 13" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,3)
- if disk.getLabel(diskDriveSide) =="C418 - blocks" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,4)
- if disk.getLabel(diskDriveSide) =="C418 - blocks" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Blocks ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,5)
- if disk.getLabel(diskDriveSide) =="C418 - blocks" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,3)
- if disk.getLabel(diskDriveSide) =="C418 - chirp" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,4)
- if disk.getLabel(diskDriveSide) =="C418 - chirp" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Chirp ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,5)
- if disk.getLabel(diskDriveSide) =="C418 - chirp" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,7)
- if disk.getLabel(diskDriveSide) =="C418 - far" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,8)
- if disk.getLabel(diskDriveSide) =="C418 - far" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Far ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,9)
- if disk.getLabel(diskDriveSide) =="C418 - far" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,7)
- if disk.getLabel(diskDriveSide) =="C418 - mall" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,8)
- if disk.getLabel(diskDriveSide) =="C418 - mall" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Mall ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,9)
- if disk.getLabel(diskDriveSide) =="C418 - mall" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,7)
- if disk.getLabel(diskDriveSide) =="C418 - mellohi" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,8)
- if disk.getLabel(diskDriveSide) =="C418 - mellohi" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Mellohi ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,9)
- if disk.getLabel(diskDriveSide) =="C418 - mellohi" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,7)
- if disk.getLabel(diskDriveSide) =="C418 - stal" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,8)
- if disk.getLabel(diskDriveSide) =="C418 - stal" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Stal ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,9)
- if disk.getLabel(diskDriveSide) =="C418 - stal" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,11)
- if disk.getLabel(diskDriveSide) =="C418 - strad" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,12)
- if disk.getLabel(diskDriveSide) =="C418 - strad" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Strad ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(3,13)
- if disk.getLabel(diskDriveSide) =="C418 - strad" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,11)
- if disk.getLabel(diskDriveSide) =="C418 - ward" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,12)
- if disk.getLabel(diskDriveSide) =="C418 - ward" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Ward ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(15,13)
- if disk.getLabel(diskDriveSide) =="C418 - ward" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,11)
- if disk.getLabel(diskDriveSide) =="C418 - 11" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,12)
- if disk.getLabel(diskDriveSide) =="C418 - 11" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" 11 ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(27,13)
- if disk.getLabel(diskDriveSide) =="C418 - 11" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,11)
- if disk.getLabel(diskDriveSide) =="wait" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,12)
- if disk.getLabel(diskDriveSide) =="wait" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.setTextColor(colors.black)
- m.write(" Wait ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(39,13)
- if disk.getLabel(diskDriveSide) =="wait" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.green) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(2,15)
- if disk.getLabel(diskDriveSide) =="pg.stillalive" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(2,16)
- if disk.getLabel(diskDriveSide) =="pg.stillalive" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.setTextColor(colors.black)
- m.write(" Still Alive ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(2,17)
- if disk.getLabel(diskDriveSide) =="pg.stillalive" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(18,15)
- if disk.getLabel(diskDriveSide) =="pg.radioloop" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(18,16)
- if disk.getLabel(diskDriveSide) =="pg.radioloop" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.setTextColor(colors.black)
- m.write(" Radio Loop ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(18,17)
- if disk.getLabel(diskDriveSide) =="pg.radioloop" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(35,15)
- if disk.getLabel(diskDriveSide) =="pg.wantyougone" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(35,16)
- if disk.getLabel(diskDriveSide) =="pg.wantyougone" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.setTextColor(colors.black)
- m.write(" Want You Gone ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(35,17)
- if disk.getLabel(diskDriveSide) =="pg.wantyougone" then m.setBackgroundColor(colors.yellow) else m.setBackgroundColor(colors.cyan) end
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(12,19)
- m.setBackgroundColor(colors.blue)
- m.setTextColor(colors.white)
- m.write(" Play ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(19,19)
- m.setBackgroundColor(colors.blue)
- m.setTextColor(colors.white)
- m.write(" Stop ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(26,19)
- m.setBackgroundColor(colors.blue)
- m.setTextColor(colors.white)
- m.write(" Eject ")
- m.setBackgroundColor(colors.black)
- m.setCursorPos(34,19)
- m.setBackgroundColor(colors.blue)
- m.setTextColor(colors.white)
- m.write(" Back ")
- m.setBackgroundColor(colors.black)
- end
- setGUI(monitorSide)
- m = peripheral.wrap(monitorSide)
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- --Play Button
- if (yPos == 19) and (xPos >= 12 and xPos <= 17) then
- setAction(monitorSide," Play! ")
- playButton(diskDriveSide)
- setGUI(monitorSide)
- --Stop Button
- elseif (yPos == 19) and (xPos >= 19 and xPos <= 24) then
- setAction(monitorSide," Stop! ")
- sleep(.5)
- stop(diskDriveSide)
- setGUI(monitorSide)
- --Eject Button
- elseif (yPos == 19) and (xPos >= 26 and xPos <= 32) then
- setAction(monitorSide," Eject! ")
- print("ejecting track")
- eject(ejectRedstoneSide)
- setGUI(monitorSide)
- --Back Button
- elseif (yPos == 19) and (xPos >= 34 and xPos <= 40) then
- setAction(monitorSide," Goodbye! ")
- sleep(2)
- m.clear()
- return
- --Cat
- elseif (yPos >= 3 and yPos <=6 ) and (xPos >= 2 and xPos <= 12) then
- setAction(monitorSide," Loading Cat... ")
- playRecord(diskDriveSide,recordRedSide,"cat")
- setGUI(monitorSide)
- --13
- elseif (yPos >= 3 and yPos <=6 ) and (xPos >= 14 and xPos <= 24) then
- setAction(monitorSide," Loading 13... ")
- playRecord(diskDriveSide,recordRedSide,"13")
- setGUI(monitorSide)
- --Blocks
- elseif (yPos >= 3 and yPos <=6 ) and (xPos >= 26 and xPos <= 36) then
- setAction(monitorSide," Loading Blocks... ")
- playRecord(diskDriveSide,recordRedSide,"blocks")
- setGUI(monitorSide)
- --Chirp
- elseif (yPos >= 3 and yPos <=6 ) and (xPos >= 38 and xPos <= 48) then
- setAction(monitorSide," Loading Chirp... ")
- playRecord(diskDriveSide,recordRedSide,"chirp")
- setGUI(monitorSide)
- --Far
- elseif (yPos >= 7 and yPos <= 9 ) and (xPos >= 2 and xPos <= 12) then
- setAction(monitorSide," Loading Far... ")
- playRecord(diskDriveSide,recordRedSide,"far")
- setGUI(monitorSide)
- --Mall
- elseif (yPos >= 7 and yPos <= 9 ) and (xPos >= 14 and xPos <= 24) then
- setAction(monitorSide," Loading Mall... ")
- playRecord(diskDriveSide,recordRedSide,"mall")
- setGUI(monitorSide)
- --Mellohi
- elseif (yPos >= 7 and yPos <= 9 ) and (xPos >= 26 and xPos <= 36) then
- setAction(monitorSide," Loading Mellohi... ")
- playRecord(diskDriveSide,recordRedSide,"mellohi")
- setGUI(monitorSide)
- --Stal
- elseif (yPos >= 7 and yPos <= 9 ) and (xPos >= 38 and xPos <= 48) then
- setAction(monitorSide," Loading Stal... ")
- playRecord(diskDriveSide,recordRedSide,"stal")
- setGUI(monitorSide)
- --Strad
- elseif (yPos >= 11 and yPos <= 14) and (xPos >= 2 and xPos <= 12) then
- setAction(monitorSide," Loading Strad... ")
- playRecord(diskDriveSide,recordRedSide,"strad")
- setGUI(monitorSide)
- --Ward
- elseif (yPos >= 11 and yPos <= 14) and (xPos >= 14 and xPos <= 24) then
- setAction(monitorSide," Loading Ward... ")
- playRecord(diskDriveSide,recordRedSide,"ward")
- setGUI(monitorSide)
- --11
- elseif (yPos >= 11 and yPos <= 14) and (xPos >= 26 and xPos <= 36) then
- setAction(monitorSide," Loading 11... ")
- playRecord(diskDriveSide,recordRedSide,"11")
- setGUI(monitorSide)
- --Wait
- elseif (yPos >= 11 and yPos <= 14) and (xPos >= 38 and xPos <= 48) then
- setAction(monitorSide," Loading Wait... ")
- playRecord(diskDriveSide,recordRedSide,"wait")
- setGUI(monitorSide)
- --Still Alive
- elseif (yPos >= 15 and yPos <= 18) and (xPos >= 2 and xPos <= 16) then
- setAction(monitorSide," Loading Still Alive...")
- playRecord(diskDriveSide,recordRedSide,"still-alive")
- setGUI(monitorSide)
- --Radio Loop
- elseif (yPos >= 15 and yPos <= 18) and (xPos >= 18 and xPos <= 33) then
- setAction(monitorSide," Loading Radio Loop... ")
- playRecord(diskDriveSide,recordRedSide,"radio-loop")
- setGUI(monitorSide)
- --Want You Gone
- elseif (yPos >= 15 and yPos <= 18) and (xPos >= 35 and xPos <= 49) then
- setAction(monitorSide," Loading WantYouGone...")
- playRecord(diskDriveSide,recordRedSide,"want-you-gone")
- setGUI(monitorSide)
- end
- end
- --m.setCursorPos(1,1)
- --m.clearLine()
- --while true do
- -- m.setCursorPos(1,1)
- -- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- -- m.clearLine()
- -- m.write(event.." => Side: " .. tostring(side) .. ", " ..
- -- "xPos: ".. xPos ..", " ..
- -- "yPos: ".. yPos)
- -- setAction(monitorSide," test ")
- --
- --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement