HDR

Music System 2.5 Infinity Evolved

HDR
Nov 14th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.38 KB | None | 0 0
  1. --# Made By HDR - @MartinRefseth #--
  2. os.loadAPI("touchpoint")
  3. for a,b in pairs(rs.getSides()) do
  4.   if peripheral.getType(b) == 'monitor' then
  5.    home = touchpoint.new(b)
  6.    settings = touchpoint.new(b)
  7.    buttonColor = touchpoint.new(b)
  8.    textColor = touchpoint.new(b)
  9.    backgroundColor = touchpoint.new(b)
  10.    local t
  11.    break
  12.   end
  13. end
  14.  
  15. if fs.exists("musicsystem.cfg") == false then
  16.  local ColorTable = {ButtonColor = "512", TextColor = "2", BackgroundColor = "128"}
  17.     writeCFG = fs.open("musicsystem.cfg", "w")
  18.     writeCFG.write( textutils.serialize( ColorTable ) )
  19.     writeCFG.close()
  20. end
  21. openCFG = fs.open( "musicsystem.cfg", "r" )
  22.   data = openCFG.readAll()
  23.   openCFG.close()
  24.   CFGData = textutils.unserialize(data)
  25.    mainCol = tonumber(CFGData.ButtonColor)
  26.    textCol = tonumber(CFGData.TextColor)
  27.    backCol = tonumber(CFGData.BackgroundColor)
  28.  
  29. --# Functions
  30. function tpoint()
  31.   t = tpage
  32. --#OverWrites Part Of Touchpoint API#--
  33.     t.draw = function(self)
  34.       local function cT(text)
  35.         x,y = term.getSize()
  36.         x1,y1 = term.getCursorPos()
  37.         term.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
  38.         term.write(text)
  39.      end
  40.                 local old = term.redirect(self.mon)
  41.                 term.setTextColor(colors.white)
  42.                 term.setBackgroundColor(backCol)
  43.                 term.clear()
  44.                 term.setCursorPos(1,1)
  45.                 term.setTextColor(textCol)
  46.                 cT(header)
  47.                 for name, buttonData in pairs(self.buttonList) do
  48.                         if buttonData.active then
  49.                                 term.setBackgroundColor(buttonData.activeColor)
  50.                                 term.setTextColor(buttonData.activeText)
  51.                         else
  52.                                 term.setBackgroundColor(buttonData.inactiveColor)
  53.                                 term.setTextColor(buttonData.inactiveText)
  54.                         end
  55.                         for i = buttonData.yMin, buttonData.yMax do
  56.                                 term.setCursorPos(buttonData.xMin, i)
  57.                                 term.write(buttonData.label[i - buttonData.yMin + 1])
  58.                         end
  59.                 end
  60.                 if old then
  61.                         term.redirect(old)
  62.                 else
  63.                         term.restore()
  64.                 end
  65.         end
  66. end
  67.  
  68. function colWrite()
  69. local ColorTable = {ButtonColor = buttonColor, TextColor = textColor, BackgroundColor = backgroundColor}
  70.     writeCFG = fs.open("musicsystem.cfg", "w")
  71.     writeCFG.write( textutils.serialize( ColorTable ) )
  72.     writeCFG.close()
  73.     os.reboot()
  74. end
  75.  
  76. function play(title)
  77.  peripheral.find("drive", disk.stopAudio)
  78.  peripheral.find( "drive", function( name )
  79.   if disk.hasAudio( name ) and disk.getAudioTitle( name ) == title then
  80.     print("Now Playing"," ",( title) )
  81.     disk.playAudio( name )
  82.   end
  83.  end )
  84. end  
  85.  
  86. function Thir()
  87.    t:flash("13")
  88.    play("C418 - 13")
  89. end
  90.  
  91. function Cat()
  92.    t:flash("Cat")
  93.    play("C418 - cat")
  94. end
  95.  
  96. function Blocks()
  97.    t:flash("Blocks")
  98.    play("C418 - blocks")
  99. end  
  100.  
  101. function Chirp()
  102.    t:flash("Chirp")
  103.    play("C418 - chirp")
  104. end  
  105.  
  106. function Far()
  107.    t:flash("Far")
  108.    play("C418 - far")
  109. end
  110.  
  111. function Mall()
  112.    t:flash("Mall")
  113.    play("C418 - mall")
  114. end
  115.  
  116. function Mellohi()
  117.    t:flash("Mellohi")
  118.    play("C418 - mellohi")
  119. end
  120.  
  121. function Stal()
  122.    t:flash("Stal")
  123.    play("C418 - stal")
  124. end
  125.  
  126. function Strad()
  127.    t:flash("Strad")
  128.    play("C418 - strad")
  129. end
  130.    
  131. function Ward()
  132.    t:flash("Ward")
  133.    play("C418 - ward")
  134. end
  135.  
  136. function Elev()
  137.    t:flash("11")
  138.    play("C418 - 11")
  139. end
  140.  
  141. function Wait()
  142.    t:flash("Wait")
  143.    play("C418 - wait")
  144. end
  145.  
  146. function Question()
  147.    t:flash("???")
  148.    play("corruption")
  149. end
  150.  
  151. function GaiaOne()
  152.    t:flash("Gaia 1")
  153.    play("botania:gaia1")
  154. end
  155.  
  156. function GaiaTwo()
  157.    t:flash("Gaia 2")
  158.    play("botania:gaia2")
  159. end
  160.  
  161. function Roop()
  162.    t:flash("R-Loop")
  163.    play("portalgun:records.radioloop")
  164. end
  165.  
  166. function Slive()
  167.    t:flash("S-Alive")
  168.    play("portalgun:records.stillalive")
  169. end
  170.  
  171. function WYG()
  172.    t:flash("WYG")
  173.    play("portalgun:records.wantyougone")
  174. end
  175.  
  176. function WDR()
  177.    t:flash("Wanderer")
  178.    play("wanderer")
  179. end
  180.  
  181. --#Stops All Music
  182. function Stop()
  183.    t:flash("Stop")
  184.    print("Stopping Disk")
  185.    peripheral.find("drive", disk.stopAudio)
  186. end
  187. function Reboot()
  188.    t:flash("Reboot")
  189.    print("Rebooting")
  190.    peripheral.find("drive", disk.stopAudio)
  191.    os.reboot()
  192. end
  193.  
  194. -- A list of all possible songs
  195. local Songs = {
  196.     Thir, Cat, Blocks, Chirp, Far, Mall, Mellohi, Stal, Strad, Ward,
  197.     Elev, Wait, Question, GaiaOne, GaiaTwo, Roop, Slive, WYG, Wander
  198. }
  199.  
  200. function Random()
  201.     t:flash("Random")
  202.     peripheral.find("drive", disk.stopAudio)
  203.     local maxSongs = #Songs -- the "#" gets the length of the list
  204.     local randomNumber = math.random( maxSongs )
  205.     Songs[randomNumber]() -- call the choosen song directly out of the list
  206. end
  207.  
  208. function update()
  209.  settings:flash("Update")
  210.  shell.run("rm startup")
  211.  shell.run("rm touchpoint")
  212.  shell.run("pastebin get Az75cPJ6 startup")
  213.  shell.run("pastebin get pFHeia96 touchpoint")
  214.  os.reboot()
  215. end
  216.  
  217. --#Button Color Functions#--
  218. function whiteCol()
  219. buttonColor = 1
  220.  colorSetText()
  221. end
  222.  
  223. function orangeCol()
  224. buttonColor = 2
  225.  colorSetText()
  226. end
  227.  
  228. function magentaCol()
  229. buttonColor = 4
  230.  colorSetText()
  231. end
  232.  
  233. function lblueCol()
  234. buttonColor = 8
  235.  colorSetText()
  236. end
  237.  
  238. function yellowCol()
  239. buttonColor = 16
  240.  colorSetText()
  241. end
  242.  
  243. function limeCol()
  244. buttonColor = 32
  245.  colorSetText()
  246. end
  247.  
  248. function pinkCol()
  249. buttonColor = 64
  250.  colorSetText()
  251. end
  252.  
  253. function grayCol()
  254. buttonColor = 128
  255.  colorSetText()
  256. end
  257.  
  258. function lgrayCol()
  259. buttonColor = 256
  260.  colorSetText()
  261. end
  262.  
  263. function cyanCol()
  264. buttonColor = 512
  265.  colorSetText()
  266. end
  267.  
  268. function purpleCol()
  269. buttonColor = 1024
  270.  colorSetText()
  271. end
  272.  
  273. function blueCol()
  274. buttonColor = 2048
  275.  colorSetText()
  276. end
  277.  
  278. function brownCol()
  279. buttonColor = 4096
  280.  colorSetText()
  281. end
  282.  
  283. function greenCol()
  284. buttonColor = 8192
  285.  colorSetText()
  286. end
  287.  
  288. function redCol()
  289. buttonColor = 16384
  290.  colorSetText()
  291. end
  292.  
  293. function blackCol()
  294. buttonColor = 32768
  295.  colorSetText()
  296. end
  297.  
  298. --#Text Color Functions#--
  299. function twhiteCol()
  300. textColor = 1
  301.  colorSetBackground()
  302. end
  303.  
  304. function torangeCol()
  305. textColor = 2
  306.  colorSetBackground()
  307. end
  308.  
  309. function tmagentaCol()
  310. textColor = 4
  311.  colorSetBackground()
  312. end
  313.  
  314. function tlblueCol()
  315. textColor = 8
  316.  colorSetBackground()
  317. end
  318.  
  319. function tyellowCol()
  320. textColor = 16
  321.  colorSetBackground()
  322. end
  323.  
  324. function tlimeCol()
  325. textColor = 32
  326.  colorSetBackground()
  327. end
  328.  
  329. function tpinkCol()
  330. textColor = 64
  331.  colorSetBackground()
  332. end
  333.  
  334. function tgrayCol()
  335. textColor = 128
  336.  colorSetBackground()
  337. end
  338.  
  339. function tlgrayCol()
  340. textColor = 256
  341.  colorSetBackground()
  342. end
  343.  
  344. function tcyanCol()
  345. textColor = 512
  346.  colorSetBackground()
  347. end
  348.  
  349. function tpurpleCol()
  350. textColor = 1024
  351.  colorSetBackground()
  352. end
  353.  
  354. function tblueCol()
  355. textColor = 2048
  356.  colorSetBackground()
  357. end
  358.  
  359. function tbrownCol()
  360. textColor = 4096
  361.  colorSetBackground()
  362. end
  363.  
  364. function tgreenCol()
  365. textColor = 8192
  366.  colorSetBackground()
  367. end
  368.  
  369. function tredCol()
  370. textColor = 16384
  371.  colorSetBackground()
  372. end
  373.  
  374. function tblackCol()
  375. textColor = 32768
  376.  colorSetBackground()
  377. end
  378.  
  379. --#Background color functions#--
  380. function bwhiteCol()
  381. backgroundColor = 1
  382.  colWrite()
  383. end
  384.  
  385. function borangeCol()
  386. backgroundColor = 2
  387.  colWrite()
  388. end
  389.  
  390. function bmagentaCol()
  391. backgroundColor = 4
  392.  colWrite()
  393. end
  394.  
  395. function blblueCol()
  396. backgroundColor = 8
  397.  colWrite()
  398. end
  399.  
  400. function byellowCol()
  401. backgroundColor = 16
  402.  colWrite()
  403. end
  404.  
  405. function blimeCol()
  406. backgroundColor = 32
  407.  colWrite()
  408. end
  409.  
  410. function bpinkCol()
  411. backgroundColor = 64
  412.  colWrite()
  413. end
  414.  
  415. function bgrayCol()
  416. backgroundColor = 128
  417.  colWrite()
  418. end
  419.  
  420. function blgrayCol()
  421. backgroundColor = 256
  422.  colWrite()
  423. end
  424.  
  425. function bcyanCol()
  426. backgroundColor = 512
  427.  colWrite()
  428. end
  429.  
  430. function bpurpleCol()
  431. backgroundColor = 1024
  432.  colWrite()
  433. end
  434.  
  435. function bblueCol()
  436. backgroundColor = 2048
  437.  colWrite()
  438. end
  439.  
  440. function bbrownCol()
  441. backgroundColor = 4096
  442.  colWrite()
  443. end
  444.  
  445. function bgreenCol()
  446. backgroundColor = 8192
  447.  colWrite()
  448. end
  449.  
  450. function bredCol()
  451. backgroundColor = 16384
  452.  colWrite()
  453. end
  454.  
  455. function bblackCol()
  456. backgroundColor = 32768
  457.  colWrite()
  458. end
  459.  
  460. function resCol()
  461. t:flash("Reset")
  462.  shell.run("rm musicsystem.cfg")
  463.  os.reboot()
  464. end
  465.  
  466. function main()
  467.  tpage = home
  468.  header = "HDR's Music System 2.5"
  469.  tpoint()
  470. end
  471.  
  472. function menu()
  473.  tpage = settings
  474.  header = "HDR's Music System 2.5"
  475.  tpoint()
  476. end
  477.  
  478. function colorSetButton()
  479.  tpage = buttonColor
  480.  header = "Select Button Color"
  481.  tpoint()
  482. end
  483.  
  484. function colorSetText()
  485.  tpage = textColor
  486.  header = "Select Text Color"
  487.  tpoint()
  488. end
  489.  
  490. function colorSetBackground()
  491.  tpage = backgroundColor
  492.  header = "Select Background Color"
  493.  tpoint()
  494. end
  495.  
  496. do
  497. --#Main Page Buttons#--
  498.  home:add("13", Thir, 2,3,12,5, mainCol, textCol, textCol , mainCol)
  499.  home:add("Cat", Cat, 14,3,24,5, mainCol, textCol, textCol , mainCol)
  500.  home:add("Blocks", Blocks, 26,3,36,5, mainCol, textCol, textCol , mainCol)
  501.  home:add("Chirp", Chirp, 38,3,48,5, mainCol, textCol, textCol , mainCol)
  502.  home:add("Far", Far, 50,3,60,5, mainCol, textCol, textCol , mainCol)
  503.  home:add("Mall", Mall, 2,7,12,9, mainCol, textCol, textCol , mainCol)
  504.  home:add("Mellohi", Mellohi, 14,7,24,9, mainCol, textCol, textCol , mainCol)
  505.  home:add("Stal", Stal, 26,7,36,9, mainCol, textCol, textCol , mainCol)
  506.  home:add("Strad", Strad, 38,7,48,9, mainCol, textCol, textCol , mainCol)
  507.  home:add("Ward", Ward, 50,7,60,9, mainCol, textCol, textCol , mainCol)
  508.  home:add("11", Elev, 2,11,12,13, mainCol, textCol, textCol , mainCol)
  509.  home:add("Wait", Wait, 14,11,24,13, mainCol, textCol, textCol , mainCol)
  510.  home:add("???", Question, 26,11,36,13, mainCol, textCol, textCol , mainCol)
  511.  home:add("Gaia 1", GaiaOne, 38,11,48,13, mainCol, textCol, textCol , mainCol)
  512.  home:add("Gaia 2", GaiaTwo, 50,11,60,13, mainCol, textCol, textCol , mainCol)
  513.  home:add("R-Loop", Roop, 8,15,18,17, mainCol, textCol, textCol , mainCol)
  514.  home:add("S-Alive", Slive, 20,15,30,17, mainCol, textCol, textCol , mainCol)
  515.  home:add("WYG", WYG, 32,15,42,17, mainCol, textCol, textCol , mainCol)
  516.  home:add("Wanderer", WDR, 44,15,54,17, mainCol, textCol, textCol , mainCol)
  517.  home:add("Random", Random, 14,19,24,19, mainCol, textCol, textCol , mainCol)
  518.  home:add("Stop", Stop, 26,19,36,19, mainCol, textCol, textCol , mainCol)
  519.  home:add("Settings", menu, 38,19,48,19, mainCol, textCol, textCol , mainCol)
  520.  
  521.  --#Settings Page Buttons#--
  522.  settings:add("Update", update, 2,3,12,5, mainCol, textCol, textCol , mainCol)
  523.  settings:add("Reboot", Reboot, 2,7,12,9, mainCol, textCol, textCol , mainCol)
  524.  settings:add("Back", main, 1,19,11,19, mainCol, textCol, textCol , mainCol)
  525.  settings:add("Customize", colorSetButton, 14,3,24,5, mainCol, textCol, textCol , mainCol)
  526.  settings:add("Reset", resCol, 50,3,60,5, mainCol, textCol, textCol, mainCol)
  527.  
  528.  
  529. --#Button Color#--
  530.  buttonColor:add("White", whiteCol, 2,3,12,5, colors.white, colors.black, colors.black, colors.white)
  531.  buttonColor:add("Orange", orangeCol, 14,3,24,5, colors.orange, colors.black, colors.black, colors.orange)
  532.  buttonColor:add("Magenta", magentaCol, 26,3,36,5, colors.magenta, colors.black, colors.black, colors.magenta)
  533.  buttonColor:add("L-Blue", lblueCol, 38,3,48,5, colors.lightBlue, colors.black, colors.black, colors.lightBlue)
  534.  buttonColor:add("Yellow", yellowCol, 50,3,60,5, colors.yellow, colors.black, colors.black, colors.yellow)
  535.  buttonColor:add("Lime", limeCol, 2,7,12,9, colors.lime, colors.black, colors.black, colors.lime)
  536.  buttonColor:add("Pink", pinkCol, 14,7,24,9, colors.pink, colors.black, colors.black, colors.pink)
  537.  buttonColor:add("Gray", grayCol, 26,7,36,9, colors.gray, colors.black, colors.black, colors.gray)
  538.  buttonColor:add("L-Gray", lgrayCol, 38,7,48,9, colors.lightGray, colors.black, colors.black, colors.lightGray)
  539.  buttonColor:add("Cyan", cyanCol, 50,7,60,9, colors.cyan, colors.black, colors.black, colors.cyan)
  540.  buttonColor:add("Purple", purpleCol, 2,11,12,13, colors.purple, colors.black, colors.black, colors.purple)
  541.  buttonColor:add("Blue", blueCol, 14,11,24,13, colors.blue, colors.black, colors.black, colors.blue)
  542.  buttonColor:add("Brown", brownCol, 26,11,36,13, colors.brown, colors.black, colors.black, colors.brown)
  543.  buttonColor:add("Green", greenCol, 38,11,48,13, colors.green, colors.black, colors.black, colors.green)
  544.  buttonColor:add("Red", redCol, 50,11,60,13, colors.red, colors.black, colors.black, colors.red)
  545.  buttonColor:add("Black", blackCol, 26,15,36,17, colors.black, colors.black, colors.white, colors.white)
  546.  buttonColor:add("Back", menu, 1,19,11,19, mainCol, colors.lime, colors.orange, colors.orange)
  547.  
  548. --#Text Color#--
  549.  textColor:add("White", twhiteCol, 2,3,12,5, colors.white, colors.black, colors.black, colors.white)
  550.  textColor:add("Orange", torangeCol, 14,3,24,5, colors.orange, colors.black, colors.black, colors.orange)
  551.  textColor:add("Magenta", tmagentaCol, 26,3,36,5, colors.magenta, colors.black, colors.black, colors.magenta)
  552.  textColor:add("L-Blue", tlblueCol, 38,3,48,5, colors.lightBlue, colors.black, colors.black, colors.lightBlue)
  553.  textColor:add("Yellow", tyellowCol, 50,3,60,5, colors.yellow, colors.black, colors.black, colors.yellow)
  554.  textColor:add("Lime", tlimeCol, 2,7,12,9, colors.lime, colors.black, colors.black, colors.lime)
  555.  textColor:add("Pink", tpinkCol, 14,7,24,9, colors.pink, colors.black, colors.black, colors.pink)
  556.  textColor:add("Gray", tgrayCol, 26,7,36,9, colors.gray, colors.black, colors.black, colors.gray)
  557.  textColor:add("L-Gray", tlgrayCol, 38,7,48,9, colors.lightGray, colors.black, colors.black, colors.lightGray)
  558.  textColor:add("Cyan", tcyanCol, 50,7,60,9, colors.cyan, colors.black, colors.black, colors.cyan)
  559.  textColor:add("Purple", tpurpleCol, 2,11,12,13, colors.purple, colors.black, colors.black, colors.purple)
  560.  textColor:add("Blue", tblueCol, 14,11,24,13, colors.blue, colors.black, colors.black, colors.blue)
  561.  textColor:add("Brown", tbrownCol, 26,11,36,13, colors.brown, colors.black, colors.black, colors.brown)
  562.  textColor:add("Green", tgreenCol, 38,11,48,13, colors.green, colors.black, colors.black, colors.green)
  563.  textColor:add("Red", tredCol, 50,11,60,13, colors.red, colors.black, colors.black, colors.red)
  564.  textColor:add("Black", tblackCol, 26,15,36,17, colors.black, colors.black, colors.white, colors.white)
  565.  
  566. --#Background Color#--
  567.  backgroundColor:add("White", bwhiteCol, 2,3,12,5, colors.white, colors.black, colors.black, colors.white)
  568.  backgroundColor:add("Orange", borangeCol, 14,3,24,5, colors.orange, colors.black, colors.black, colors.orange)
  569.  backgroundColor:add("Magenta", bmagentaCol, 26,3,36,5, colors.magenta, colors.black, colors.black, colors.magenta)
  570.  backgroundColor:add("L-Blue", blblueCol, 38,3,48,5, colors.lightBlue, colors.black, colors.black, colors.lightBlue)
  571.  backgroundColor:add("Yellow", byellowCol, 50,3,60,5, colors.yellow, colors.black, colors.black, colors.yellow)
  572.  backgroundColor:add("Lime", blimeCol, 2,7,12,9, colors.lime, colors.black, colors.black, colors.lime)
  573.  backgroundColor:add("Pink", bpinkCol, 14,7,24,9, colors.pink, colors.black, colors.black, colors.pink)
  574.  backgroundColor:add("Gray", bgrayCol, 26,7,36,9, colors.gray, colors.black, colors.black, colors.gray)
  575.  backgroundColor:add("L-Gray", blgrayCol, 38,7,48,9, colors.lightGray, colors.black, colors.black, colors.lightGray)
  576.  backgroundColor:add("Cyan", bcyanCol, 50,7,60,9, colors.cyan, colors.black, colors.black, colors.cyan)
  577.  backgroundColor:add("Purple", bpurpleCol, 2,11,12,13, colors.purple, colors.black, colors.black, colors.purple)
  578.  backgroundColor:add("Blue", bblueCol, 14,11,24,13, colors.blue, colors.black, colors.black, colors.blue)
  579.  backgroundColor:add("Brown", bbrownCol, 26,11,36,13, colors.brown, colors.black, colors.black, colors.brown)
  580.  backgroundColor:add("Green", bgreenCol, 38,11,48,13, colors.green, colors.black, colors.black, colors.green)
  581.  backgroundColor:add("Red", bredCol, 50,11,60,13, colors.red, colors.black, colors.black, colors.red)
  582.  backgroundColor:add("Black", bblackCol, 26,15,36,17, colors.black, colors.black, colors.white, colors.white)
  583. end
  584.  
  585. main()
  586. while true do
  587.     t:draw()
  588.     local event, p1 = t:handleEvents(os.pullEvent())
  589.     if event == "button_click" then
  590.         t.buttonList[p1].func()
  591.     end
  592. end
Add Comment
Please, Sign In to add comment