Fredyman_95

Theme player

May 20th, 2022 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 28.22 KB | None | 0 0
  1. --[[Program Info
  2.     Stargate Theme player
  3.  
  4.     System requirements:
  5.     Tier 3 GPU
  6.     Tier 3 Screen
  7.     Redstone IO
  8.  
  9.     Music disc change system requiremets:
  10.     EnderIO
  11.     Extra Utilities 2
  12.     Custom Records - not required (only for custom music discs)
  13.     --]]
  14.  
  15. -- Changelog ----------------------------------------------
  16.  
  17. local changelog = [[
  18.   - Optimalization of progress bar
  19.   - Edited functions
  20.   - Added new Info screens - disc status
  21.   ]]
  22. -- End of Changelog ---------------------------------------
  23.  
  24. -- Start --------------------------------------------------
  25.  
  26.   local term = require("term")
  27.   local component = require("component")
  28.   local computer = require("computer")
  29.   local event = require("event")
  30.   local unicode = require("unicode")
  31.   local colors = require("colors")
  32.   local sides = require("sides")
  33.  
  34.   local gpu = component.gpu
  35.   local screen = component.screen
  36.   local creators = [[Augur ShicKla, TheRedCreations, Fredyman_95]]
  37.   local version = [[1.4.0.0]]
  38. -- End of start -------------------------------------------
  39.  
  40. -- Sides config -------------------------------------------
  41.  
  42.   local song1 = sides.north
  43.   local song2 = sides.south
  44.   local song3 = sides.top
  45.   local song4 = sides.west
  46.   local song5 = sides.east
  47.   local stopSong = sides.bottom
  48. -- End of Sides config ------------------------------------
  49.  
  50. -- System requirements check ------------------------------
  51.  
  52.   if gpu.maxResolution() < 100 then
  53.       io.stderr:write("Tier 3 GPU and Screen Required")
  54.       computer.beep()
  55.       os.sleep(0.2)
  56.       computer.beep()
  57.       os.exit(1)
  58.   end
  59.  
  60.   if not component.isAvailable("redstone") then
  61.       io.stderr:write("No RedstoneIO Connected.")
  62.       computer.beep()
  63.       os.sleep(0.2)
  64.       computer.beep()
  65.       os.sleep(0.2)
  66.       computer.beep()
  67.       os.exit(1)
  68.   end
  69. -- end of System requirements check -----------------------
  70.  
  71. -- Declarations--------------------------------------------
  72.  
  73.   local ActiveButtons = {}
  74.   local buttons = {}
  75.   local User = ""
  76.   local mainScreen = function() end
  77.   local ErrorMessage = ""
  78.   local StopPlaying = false
  79.   local rs = component.redstone
  80.  
  81.   local logoColor = 0xFFFFFF --Default 0xFFFFFF white
  82.   local AdminList = {"Example_Name","Fredyman_95","ShicKla","TheRedCreations","MineDragonCZ_","Matousss"}
  83.   local mainloop = true
  84.   screen.setTouchModeInverted(true)
  85. -- end of Declarations ------------------------------------
  86.  
  87. -- Colors Declarations ------------------------------------
  88.  
  89.   local white = 0xFFFFFF
  90.   local blue = 0x00B6FF
  91.   local darkBlue = 0x0049FF
  92.   local red = 0xAA0000  
  93.   local darkRed = 0x660000
  94.   local grey = 0xB4B4B4
  95.   local lightGrey =0xE1E1E1
  96.   local mediumGrey = 0x787878
  97.   local darkGrey = 0x4B4B4B
  98. -- End of colors Declarations -----------------------------
  99.  
  100. -- Player settings ----------------------------------------
  101.  
  102.   local barSymbol = [[]]  
  103. -- End of player settings ---------------------------------
  104.  
  105. -- Restart of RedstoneIO -> outputs -----------------------
  106.  
  107.   rs.setOutput(song1, 0)
  108.   rs.setOutput(song2, 0)
  109.   rs.setOutput(song3, 0)
  110.   rs.setOutput(song4, 0)
  111.   rs.setOutput(song5, 0)
  112.   rs.setOutput(stopSong, 0)
  113. -- End of retart of RedstoneIO -> outputs -----------------
  114.  
  115. -- Buttons Objects === by Augur ShicKla === ---------------
  116.  
  117.   local Button = {}
  118.   Button.__index = Button
  119.   function Button.new(xPos, yPos, width, height, label, func, border)
  120.     local self = setmetatable({}, Button)
  121.     if xPos < 1 or xPos > term.window.width then xPos = 1 end
  122.     if yPos < 1 or yPos > term.window.height then yPos = 1 end
  123.     if (width-2) < unicode.len(label) then width = unicode.len(label)+2 end
  124.     if height < 3 then height = 3 end
  125.     if border == nil then
  126.       self.border = true
  127.     else
  128.       self.border = border
  129.     end
  130.     self.xPos = xPos
  131.     self.yPos = yPos
  132.     self.width = width
  133.     self.height = height
  134.     self.label = label
  135.     self.func = func
  136.     self.visible = false
  137.     self.disabled = false
  138.     return self
  139.   end
  140.  
  141.   function Button.display(self, x, y)
  142.     table.insert(ActiveButtons, 1, self)
  143.     if (self.width-2) < unicode.len(self.label) then self.width = unicode.len(self.label)+2 end
  144.     if x ~= nil and y ~= nil then
  145.       self.xPos = x
  146.       self.yPos = y
  147.     end
  148.         if self.border then
  149.       gpu.fill(self.xPos+1, self.yPos, self.width-2, 1, "─")
  150.       gpu.fill(self.xPos+1, self.yPos+self.height-1, self.width-2, 1, "─")
  151.       gpu.fill(self.xPos, self.yPos+1, 1, self.height-2, "│")
  152.       gpu.fill(self.xPos+self.width-1, self.yPos+1, 1, self.height-2, "│")
  153.       gpu.set(self.xPos, self.yPos, "┌")
  154.       gpu.set(self.xPos+self.width-1, self.yPos, "┐")
  155.       gpu.set(self.xPos, self.yPos+self.height-1, "└")
  156.       gpu.set(self.xPos+self.width-1, self.yPos+self.height-1, "┘")
  157.     end
  158.     gpu.set(self.xPos+1, self.yPos+1, self.label)
  159.     self.visible = true
  160.   end
  161.  
  162.   function Button.hide(self)
  163.     self.visible = false
  164.     for i,v in ipairs(ActiveButtons) do
  165.       if v == self then table.remove(ActiveButtons, i) end
  166.     end
  167.     if self.border then
  168.       gpu.fill(self.xPos, self.yPos, self.width, self.height, " ")
  169.     else
  170.       gpu.fill(self.xPos+1, self.yPos+1, self.width-2, 1, " ")
  171.     end
  172.   end
  173.  
  174.   function Button.disable(self, bool)
  175.     if bool == nil then
  176.       self.disabled = false
  177.     else
  178.       self.disabled = bool
  179.     end
  180.     if self.disabled then gpu.setForeground(0x0F0F0F) end
  181.     if self.visible then self:display() end
  182.     gpu.setForeground(0xFFFFFF)
  183.   end
  184.  
  185.   function Button.touch(self, x, y)
  186.     local wasTouched = false
  187.     if self.visible and not self.disabled then  
  188.       if self.border then
  189.         if x >= self.xPos and x <= (self.xPos+self.width-1) and y >= self.yPos and y <= (self.yPos+self.height-1) then wasTouched = true end
  190.       else
  191.         if x >= self.xPos+1 and x <= (self.xPos+self.width-2) and y >= self.yPos+1 and y <= (self.yPos+self.height-2) then wasTouched = true end
  192.       end
  193.     end
  194.     if wasTouched then
  195.       gpu.setBackground(0x878787)
  196.       gpu.set(self.xPos+1, self.yPos+1, self.label)
  197.       gpu.setBackground(0x000000)
  198.       if self.visible then gpu.set(self.xPos+1, self.yPos+1, self.label) end
  199.       self.func()
  200.     end
  201.     return wasTouched
  202.   end
  203.  
  204.   function Button.forceTouch(self)
  205.     self:touch(self.xPos+1, self.yPos+1)
  206.   end
  207. -- end of Buttons Objects === by Augur ShicKla === --------
  208.  
  209. -- Interuption --------------------------------------------
  210.  
  211.   local function isAuthorized(name)
  212.       local authorized = false
  213.       if #AdminList == 0 then
  214.         authorized = true
  215.       else
  216.         for _,v in ipairs(AdminList) do
  217.           if string.lower(v) == string.lower(name) then
  218.             authorized = true
  219.             break
  220.           end
  221.         end
  222.       end
  223.       return authorized
  224.     end
  225. -- End of Interuption -------------------------------------
  226.  
  227. -- Events -------------------------------------------------
  228.  
  229.   local Events = {}
  230.   Events.key_down = event.listen("key_down", function(_, keyboardAddress, chr, code, playerName)
  231.     User = playerName
  232.   end)
  233.  
  234.   Events.key_up = event.listen("key_up", function(_, keyboardAddress, chr, code, playerName)
  235.     User = ""
  236.   end)
  237.  
  238.   Events.interrupted = event.listen("interrupted", function()
  239.     if isAuthorized(User) then
  240.       mainloop = false
  241.     end
  242.   end)
  243.  
  244.   Events.touch = event.listen("touch", function(_, screenAddress, x, y, button, playerName)
  245.     local success, msg = xpcall(function()
  246.       if button == 0 then
  247.         for i,v in ipairs(ActiveButtons) do
  248.           if v:touch(x,y) then break end
  249.         end
  250.       end
  251.     end, debug.traceback)
  252.     if not success then
  253.       ErrorMessage = msg
  254.       mainloop = false
  255.     end
  256.   end)
  257. -- end of Events ------------------------------------------
  258.  
  259. -- Pictures -----------------------------------------------
  260.  
  261. local mainHeader = [[
  262.  ████████╗██╗  ██╗███████╗███╗   ███╗███████╗    ██████╗ ██╗      █████╗ ██╗   ██╗███████╗██████╗
  263.  ╚══██╔══╝██║  ██║██╔════╝████╗ ████║██╔════╝    ██╔══██╗██║     ██╔══██╗╚██╗ ██╔╝██╔════╝██╔══██╗
  264.     ██║   ███████║█████╗  ██╔████╔██║█████╗      ██████╔╝██║     ███████║ ╚████╔╝ █████╗  ██████╔╝
  265.     ██║   ██╔══██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██╔═══╝ ██║     ██╔══██║  ╚██╔╝  ██╔══╝  ██╔══██╗
  266.     ██║   ██║  ██║███████╗██║ ╚═╝ ██║███████╗    ██║     ███████╗██║  ██║   ██║   ███████╗██║  ██║
  267.     ╚═╝   ╚═╝  ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚═╝     ╚══════╝╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝]]
  268.        
  269. local logoSG1 = [[    
  270.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣶⣿⣿⣿⣿⣷⣄
  271.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⡟⠁⠈⢻⣿⣿⡇
  272.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣧⣀⢀⣼⣿⣿⡇
  273.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⣿⣿⣿⣿⠿⠋
  274.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⡀
  275.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⡀
  276.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣿⣿⡿⢿⣿⣿⣦⡀
  277.        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣿⠏⠀⠀⠹⣿⣿⣷⡄
  278.        ⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⡿⠇⠀⠀⠀⠀⠈⢻⣿⣿⣦⡀
  279.        ⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣷⣄
  280.        ⠀⠀⠀⠀⢀⣴⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣦⡀
  281.        ⠀⠀⠀⢀⣾⣿⣿⠏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣦
  282.        ⠀⢀⣾⣿⣿⣿⣟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣹⣿⣿⣿⣷⡀
  283.        ⠰⠿⠿⠿⠿⠿⠿⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠾⠿⠿⠿⠿⠿⠿⠆]]
  284.  
  285. local logoAtlantis = [[
  286.   ⢀⣤⣄
  287.         ⢺⣿⣿⠂⠀⠀⠀⠀⠀⠀⠀⢰⣶⣶⣀⠀⠀⠀⣠⣤⡀
  288.         ⠀⠸⡆⠀⠀⠀⠀⣀⣤⣀⡴⠚⠻⠟⠉⠉⠉⠛⢿⣿⡿⠦⠤⣤⣀⣴⣶⣄
  289.         ⠀⠀⣧⠀⠀⠀⠀⢿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⡿⠋
  290.         ⠀⢰⣾⣶⡀⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣶⣄⠀⠀⠀⢸
  291.         ⠀⠘⠿⣟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠿⢯⡀⠀⠀⣸
  292.         ⠀⠀⠀⢹⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⣀⣿
  293.         ⠀⠀⠀⠈⣧⠀⠀⢠⣾⣿⡆⠀⠀⠀⠀⠀⢠⣤⣄⣀⣀⣠⣤⠴⣿⣿⡷
  294.         ⠀⠀⠀⢠⣿⣿⡖⠋⠛⠛⠁⠀⠀⠀⢀⣠⠿⣿⡿⠋⠁⠀⠀⠀⠈⠉
  295.         ⠀⠀⠀⠀⠙⠛⢧⡀⠀⠀⢠⣾⣷⡞⠉⠀⢰⠃
  296.         ⠀⠀⠀⠀⠀⠀⢰⣿⣿⡇⠈⠻⠟⠁⠀⣀⡟
  297.         ⠀⠀⠀⠀⠀⠀⠀⠙⠋⠁⠀⠀⠀⠀⣼⣿⣿
  298.         ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠉]]
  299.  
  300. local logoUniTheme = [[
  301.   ⠀⣠⣴⣶⣶⣤⡀
  302.                   ⢸⣿⣿⠛⢻⣿⣿
  303.                   ⠸⣿⣿⣶⣾⣿⡿
  304.                   ⠀⠉⠛⠿⠟⠋⠁
  305.                   ⠀⠀⢀⣠⣀
  306.                   ⠀⠀⢸⣿⣿
  307.                   ⠀⠀⢸⣿⣿
  308.                   ⠀⠀⠈⠛⠋
  309.                   ⠀⠀⣠⣤⣤⣀
  310.                   ⠀⢸⣿⣿⣿⣿⡄
  311.                   ⠀⠈⠻⢿⡿⠟
  312.                   ⠀⠀⠀⣀⡀
  313.                   ⠀⠀⢰⣿⣿
  314.                   ⠀⠀⢸⣿⣿
  315.                   ⠀⠀⠘⠿⠟ ]]
  316.  
  317. local logoUniOpening = [[
  318.   ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇   ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
  319.        ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇   ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
  320.        ⣿⣿⣿⡏⠉⠉⠉⠉⠉⠉⣿⣿⣿⡇   ⣿⣿⣿⡏⠉⠉⠉⠉⠉⠉⣿⣿⣿⡇
  321.        ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇   ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇
  322.        ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇   ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇
  323.        ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇   ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇
  324.        ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇   ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇
  325.        ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇   ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇
  326.        ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇   ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇
  327.        ⣿⣿⣿⣧⣤⣤⣤⣤⣤⣤⣿⣿⣿⡇   ⣿⣿⣿⣧⣤⣤⣤⣤⣤⣤⣿⣿⣿⡇
  328.        ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇   ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
  329.        ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇   ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
  330.        ⠀⠀⠀⠀⠀⣿⣿⣿⡇             ⣿⣿⣿⡇
  331.        ⠀⠀⠀⠀⠀⣿⣿⣿⡇             ⣿⣿⣿⡇
  332.        ⠀⠀⠀⠀⠀⣿⣿⣿⡇             ⣿⣿⣿⡇]]
  333.  
  334. local logoUniGauntlet = [[
  335. ⠀⣠⣴⣶⣶⣤⡀    ⠀⢀⣠⣤⣶⣤⣄      ⠀⢠⣶⡆
  336.       ⢸⣿⣿⠛⢻⣿⣿    ⢠⣿⣿⡿⠿⢿⣿⣷⡄    ⠀⢸⣿⡇
  337.       ⠸⣿⣿⣶⣾⣿⡿    ⣾⣿⣿⠀⠀⠀⣿⣿⡇    ⠀⢸⣿⡇
  338.       ⠀⠉⠛⠿⠟⠋⠁    ⠸⣿⣿⣦⣤⣴⣿⣿⠃    ⠀⠈⠛⠁
  339.       ⠀⠀⢀⣠⣀       ⠈⠻⠿⠿⠿⠛⠁     ⠀⢀⣀
  340.       ⠀⠀⢸⣿⣿                   ⣴⣿⣿⣿⣆
  341.       ⠀⠀⢸⣿⣿      ⠀⠀⣀⣤⣤⣄⡀      ⣿⣿⣿⣿⡿
  342.       ⠀⠀⠈⠛⠋      ⢠⣾⣿⣿⠿⣿⣿⣷⡀    ⠈⠉⠉⠉
  343.       ⠀⠀⣠⣤⣤⣀     ⣾⣿⣿⠁⠀⠈⣿⣿⡇    ⠀⠀⢀⡀
  344.       ⠀⢸⣿⣿⣿⣿⡄    ⠸⣿⣿⣦⣤⣴⣿⣿⠃    ⠀⣴⣿⠟
  345.       ⠀⠈⠻⢿⡿⠟     ⠀⠈⠻⠿⠿⠿⠛⠁     ⢸⣿⡏
  346.       ⠀⠀⠀⣀⡀                   ⠘⢿⣷⣄
  347.       ⠀⠀⢰⣿⣿      ⠀⠀⣴⣿⣿⣿⣦        ⢹⣿
  348.       ⠀⠀⢸⣿⣿       ⠘⣿⣿⣿⣿⣿        ⣼⣿
  349.       ⠀⠀⠘⠿⠟        ⠙⠻⠿⠟⠁      ⠀⠸⠿⠋]]
  350. -- End of pictures ----------------------------------------
  351.  
  352. -- Functions ----------------------------------------------
  353.   local function setScreenResolution()
  354.       gpu.setResolution(104, 43)
  355.   end
  356.  
  357.   local function screenClear()
  358.       buttons.SG1:hide()
  359.       buttons.SGA:hide()
  360.       buttons.SGUT:hide()
  361.       buttons.SGUO:hide()
  362.       buttons.SGUG:hide()
  363.       buttons.STOP:hide()
  364.       buttons.PrevSG1:hide()
  365.       buttons.PrevA:hide()
  366.       buttons.PrevUT:hide()
  367.       buttons.PrevUO:hide()
  368.       buttons.NextA:hide()
  369.       buttons.NextUT:hide()
  370.       buttons.NextUO:hide()
  371.       buttons.NextUG:hide()
  372.       -------------------------------
  373.       buttons.SG1:disable(true)
  374.       buttons.SGA:disable(true)
  375.       buttons.SGUT:disable(true)
  376.       buttons.SGUO:disable(true)
  377.       buttons.SGUG:disable(true)
  378.       buttons.STOP:disable(true)
  379.       buttons.PrevSG1:disable(true)
  380.       buttons.PrevA:disable(true)
  381.       buttons.PrevUT:disable(true)
  382.       buttons.PrevUO:disable(true)
  383.       buttons.NextA:disable(true)
  384.       buttons.NextUT:disable(true)
  385.       buttons.NextUO:disable(true)
  386.       buttons.NextUG:disable(true)
  387.       term.clear()
  388.   end
  389.  
  390.   local function screenHeader(HeaderColor)
  391.       term.setCursor(1, 3)
  392.       gpu.setForeground(HeaderColor)
  393.       print(mainHeader)
  394.       gpu.setForeground(white)
  395.   end
  396.  
  397.   local function removeDisc(removeTime)
  398.       rs.setOutput(stopSong, 15)
  399.       os.sleep(removeTime)
  400.       rs.setOutput(stopSong, 0)
  401.   end
  402.  
  403.   local function insertDisc(songNum, preInsertPause, insertPause)
  404.       StopPlaying = false
  405.       removeDisc(0.5)
  406.       os.sleep(preInsertPause)
  407.       rs.setOutput(songNum, 15)
  408.       os.sleep(insertPause)
  409.       rs.setOutput(songNum, 0)
  410.   end
  411.  
  412.   local function convert(timeValue)
  413.       local timeValue = tonumber(timeValue)
  414.       if timeValue <= 0 then
  415.           mins = "00"
  416.           secs = "00"
  417.       else
  418.           hours = string.format("%02.f", math.floor(timeValue/3600));
  419.           mins = string.format("%02.f", math.floor(timeValue/60 - (hours*60)));
  420.           secs = string.format("%02.f", math.floor(timeValue - hours*3600 - mins *60));
  421.       end
  422.   end
  423.  
  424.   local function albumLogo(logoPosX, logoPosY, pictureColor, songPicture)
  425.       term.setCursor(logoPosX, logoPosY)
  426.       gpu.setForeground(pictureColor)
  427.       print(songPicture)
  428.       gpu.setForeground(white)
  429.       term.setCursor(3, 12)
  430.       print("┌─────────────────────────────────────────┐")
  431.       local columb = 3
  432.       local line = 13
  433.           for i = 0, 15, 1 do
  434.               term.setCursor(columb, line)
  435.               print("│")
  436.               columb = columb + 42
  437.               term.setCursor(columb, line)
  438.               print("│")
  439.               line = line + 1
  440.               columb = 3
  441.           end
  442.       term.setCursor(columb, line)
  443.       print("└─────────────────────────────────────────┘")
  444.   end
  445.  
  446.   local function infoText(textPosX, textPosY, space1, space2, line1, line2)
  447.       term.setCursor(textPosX, textPosY)
  448.       print("Now is playing:")
  449.       textPosY = textPosY + space1 + 1
  450.       term.setCursor(textPosX, textPosY)
  451.       print(line1)
  452.       textPosY = textPosY + space2 + 1
  453.       term.setCursor(textPosX, textPosY)
  454.       print(line2)
  455.   end
  456.  
  457.   local function progressBarTable(totalTime)
  458.       term.setCursor(2, 39)
  459.       print("┌───────────────────────────────────────────────────────────────────────────────────────────────────┐")
  460.       term.setCursor(2, 40)
  461.       print("│                                                                                                   │")
  462.       term.setCursor(2, 41)
  463.       print("└───────────────────────────────────────────────────────────────────────────────────────────────────┘")
  464.       term.setCursor(98, 42)
  465.       convert(totalTime)
  466.       print(mins..":"..secs)
  467.   end
  468.  
  469.   local function progressBar(duration, barColor)
  470.       local loopTime = duration - 1
  471.       local barPositionX = 3
  472.       local playedTime = 0
  473.       local add2 = duration * 10
  474.       local add = 99 / add2
  475.  
  476.           for i=0, loopTime, 1 do                        
  477.               gpu.setForeground(white)
  478.               convert(playedTime)
  479.               term.setCursor(3, 42)
  480.               print(mins..":"..secs)
  481.               playedTime = playedTime + 1
  482.                   for i=0, 9, 1 do                      
  483.                       gpu.setForeground(barColor)
  484.                       term.setCursor(barPositionX, 40)
  485.                       print(barSymbol)
  486.                       barPositionX = barPositionX + add
  487.                       if StopPlaying then break end
  488.                       os.sleep(0.1)
  489.                   end
  490.               if StopPlaying then break end
  491.           end
  492.       gpu.setForeground(white)
  493.       return
  494.   end
  495.  
  496.   local function playerArrows(played)
  497.     if played == 1 then
  498.         buttons.NextA:display()
  499.         -----------------------------
  500.         buttons.NextA:disable(false)
  501.     elseif played == 2 then
  502.         buttons.PrevSG1:display()
  503.         buttons.NextUT:display()
  504.         -----------------------------
  505.         buttons.PrevSG1:disable(false)
  506.         buttons.NextUT:disable(false)
  507.     elseif played == 3 then
  508.         buttons.PrevA:display()
  509.         buttons.NextUO:display()
  510.         -----------------------------
  511.         buttons.PrevA:disable(false)
  512.         buttons.NextUO:disable(false)
  513.     elseif played == 4 then
  514.         buttons.PrevUT:display()
  515.         buttons.NextUG:display()
  516.         -----------------------------
  517.         buttons.PrevUT:disable(false)
  518.         buttons.NextUG:disable(false)
  519.     elseif played == 5 then
  520.         buttons.PrevUO:display()
  521.         -----------------------------
  522.         buttons.PrevUO:disable(false)
  523.     else
  524.         os.sleep(0.1)
  525.     end
  526.   end
  527. -- End of Functions ---------------------------------------
  528.  
  529. -- Screens ------------------------------------------------
  530.  
  531.   local function loadingScreen(bootTime)
  532.       screenClear()
  533.       setScreenResolution()
  534.       screenHeader(logoColor)
  535.       computer.beep()
  536.       gpu.set(44, 9, "Version:")
  537.       gpu.set(53, 9, version)
  538.       gpu.set(2, 11, "Created by:")
  539.       gpu.set(2, 12, creators)
  540.       term.setCursor(2, 20)
  541.       print("Changelog:")
  542.       term.setCursor(1, 22)
  543.       print(changelog)
  544.       os.sleep(bootTime)
  545.   end
  546.  
  547.   local function mainScreen()
  548.       screenClear()
  549.       setScreenResolution()
  550.       screenHeader(logoColor)
  551.       buttons.SG1:display()
  552.       buttons.SGA:display()
  553.       buttons.SGUT:display()
  554.       buttons.SGUO:display()
  555.       buttons.SGUG:display()
  556.       -----------------------------
  557.       buttons.SG1:disable(false)
  558.       buttons.SGA:disable(false)
  559.       buttons.SGUT:disable(false)
  560.       buttons.SGUO:disable(false)
  561.       buttons.SGUG:disable(false)
  562.   end
  563.  
  564.   local function insertDiscScreen()
  565.       screenClear()
  566.       gpu.setResolution(19, 3)
  567.       term.setCursor(2, 2)
  568.       print("Inserting disc...")
  569.   end
  570.  
  571.   local function removeDiscScreen()
  572.       screenClear()
  573.       gpu.setForeground(white)
  574.       gpu.setResolution(19, 3)
  575.       term.setCursor(2, 2)
  576.       print("Removing  disc...")
  577.   end
  578.  
  579.   local function playScreen(colorHeader, PosXlogo, PosYlogo, colorImage, Image, PosXtext, PosYtext, freeLine1, freeLine2, text1, text2, pageNum, durationTime, colorBar)
  580.       screenClear()
  581.       setScreenResolution()
  582.       screenHeader(colorHeader)
  583.       albumLogo(PosXlogo, PosYlogo, colorImage, Image)
  584.       infoText(PosXtext, PosYtext, freeLine1, freeLine2, text1, text2)
  585.       buttons.STOP:display()
  586.       -----------------------------
  587.       buttons.STOP:disable(false)
  588.       playerArrows(pageNum)
  589.       progressBarTable(durationTime)
  590.       progressBar(durationTime, colorBar)
  591.       mainScreen()
  592.   end
  593. -- End of Screens -----------------------------------------
  594.  
  595. -- Buttons ------------------------------------------------
  596.  
  597.   buttons = {
  598.       SG1 = Button.new(4, 10, 96, 5, "Stargate SG-1 Theme", function()
  599.                    computer.beep()
  600.                    insertDiscScreen()
  601.                    insertDisc(song1, 1, 0.5)
  602.                    playScreen(red, 20, 13, darkRed, logoSG1, 50, 12, 1, 0, "Stargate SG-1 theme", "David Arnold", 1, 59, red)
  603.       end),
  604.  
  605.       SGA = Button.new(4, 16, 96, 5, "Stargate Atlantis Theme", function()
  606.               computer.beep()
  607.               insertDiscScreen()
  608.               insertDisc(song2, 1, 0.5)
  609.               playScreen(blue, 7, 15, darkBlue, logoAtlantis, 50, 12, 1, 0, "Stargate SGA theme", "Joel Goldsmith", 2, 61, blue)
  610.       end),
  611.  
  612.       SGUT = Button.new(4, 22, 96, 5, "Stargate Universe Opening theme - Destiny arrival", function()
  613.               computer.beep()
  614.               insertDiscScreen()
  615.               insertDisc(song3, 1, 0.5)
  616.               playScreen(grey, 17, 13, lightGrey, logoUniTheme, 50, 12, 1, 0, "Stargate Universe theme", "Joel Goldsmith", 3, 126, grey)
  617.       end),
  618.  
  619.       SGUO = Button.new(4, 28, 96, 5, "Stargate Universe Opening", function()
  620.               computer.beep()
  621.               insertDiscScreen()
  622.               insertDisc(song4, 1, 0.5)
  623.               playScreen(grey, 6, 13, mediumGrey, logoUniOpening, 50, 12, 1, 0, "Stargate Universe Opening", "Joel Goldsmith", 4, 51, grey)
  624.       end),
  625.  
  626.       SGUG = Button.new(4, 34, 96, 5, "Stargate Universe Gauntlet", function()
  627.               computer.beep()
  628.               insertDiscScreen()
  629.               insertDisc(song5, 1, 0.5)
  630.               playScreen(grey, 8, 13, darkGrey, logoUniGauntlet, 50, 12, 1, 0, "Stargate Universe Gauntlet", "Joel Goldsmith", 5, 161, grey)
  631.       end),
  632.  
  633.       STOP = Button.new(49, 36, 6, 3, "STOP", function()
  634.               computer.beep()
  635.               removeDiscScreen()
  636.               removeDisc(0.5)
  637.               StopPlaying = true
  638.       end),
  639.  
  640.     NextA = Button.new(56, 36, 5, 3, "───►", function()
  641.               computer.beep()
  642.               removeDiscScreen()
  643.               removeDisc(0.5)
  644.               StopPlaying = true
  645.               insertDiscScreen()
  646.               insertDisc(song2, 1, 0.5)
  647.               playScreen(blue, 7, 15, darkBlue, logoAtlantis, 50, 12, 1, 0, "Stargate SGA theme", "Joel Goldsmith", 2, 61, blue)
  648.     end),
  649.  
  650.     NextUT = Button.new(56, 36, 5, 3, "───►", function()
  651.               computer.beep()
  652.               removeDiscScreen()
  653.               removeDisc(0.5)
  654.               StopPlaying = true
  655.               insertDiscScreen()
  656.               insertDisc(song3, 1, 0.5)
  657.               playScreen(grey, 17, 13, lightGrey, logoUniTheme, 50, 12, 1, 0, "Stargate Universe theme", "Joel Goldsmith", 3, 126, grey)
  658.     end),
  659.  
  660.     NextUO = Button.new(56, 36, 5, 3, "───►", function()
  661.               computer.beep()
  662.               removeDiscScreen()
  663.               removeDisc(0.5)
  664.               StopPlaying = true
  665.               insertDiscScreen()
  666.               insertDisc(song4, 1, 0.5)
  667.               playScreen(grey, 6, 13, mediumGrey, logoUniOpening, 50, 12, 1, 0, "Stargate Universe Opening", "Joel Goldsmith", 4, 51, grey)
  668.     end),
  669.  
  670.     NextUG = Button.new(56, 36, 5, 3, "───►", function()
  671.               computer.beep()
  672.               removeDiscScreen()
  673.               removeDisc(0.5)
  674.               StopPlaying = true
  675.               insertDiscScreen()
  676.               insertDisc(song5, 1, 0.5)
  677.               playScreen(grey, 8, 13, darkGrey, logoUniGauntlet, 50, 12, 1, 0, "Stargate Universe Gauntlet", "Joel Goldsmith", 5, 161, grey)
  678.     end),
  679.    
  680.     PrevUO = Button.new(42, 36, 5, 3, "◄───", function()
  681.               computer.beep()
  682.               removeDiscScreen()
  683.               removeDisc(0.5)
  684.               StopPlaying = true
  685.               insertDiscScreen()
  686.               insertDisc(song4, 1, 0.5)
  687.               playScreen(grey, 6, 13, mediumGrey, logoUniOpening, 50, 12, 1, 0, "Stargate Universe Opening", "Joel Goldsmith", 4, 51, grey)
  688.     end),
  689.    
  690.     PrevUT = Button.new(42, 36, 5, 3, "◄───", function()
  691.               computer.beep()
  692.               removeDiscScreen()
  693.               removeDisc(0.5)
  694.               StopPlaying = true
  695.               insertDiscScreen()
  696.               insertDisc(song3, 1, 0.5)
  697.               playScreen(grey, 17, 13, lightGrey, logoUniTheme, 50, 12, 1, 0, "Stargate Universe theme", "Joel Goldsmith", 3, 126, grey)
  698.     end),
  699.  
  700.     PrevA = Button.new(42, 36, 5, 3, "◄───", function()
  701.               computer.beep()
  702.               removeDiscScreen()
  703.               removeDisc(0.5)
  704.               StopPlaying = true
  705.               insertDiscScreen()
  706.               insertDisc(song2, 1, 0.5)
  707.               playScreen(blue, 7, 15, darkBlue, logoAtlantis, 50, 12, 1, 0, "Stargate SGA theme", "Joel Goldsmith", 2, 61, blue)
  708.     end),
  709.  
  710.     PrevSG1 = Button.new(42, 36, 5, 3, "◄───", function()
  711.               computer.beep()
  712.               removeDiscScreen()
  713.               removeDisc(0.5)
  714.               StopPlaying = true
  715.               insertDiscScreen()
  716.               insertDisc(song1, 1, 0.5)
  717.               playScreen(red, 20, 13, darkRed, logoSG1, 50, 12, 1, 0, "Stargate SG-1 theme", "David Arnold", 1, 59, red)
  718.     end),
  719.   }      
  720. -- End of buttons -----------------------------------------
  721.  
  722. -- Program ------------------------------------------------
  723.  
  724. loadingScreen(5)
  725. mainScreen()
  726.  
  727. while mainloop do
  728.   os.sleep(0.1)
  729. end
  730.  
  731. screenClear()
  732. gpu.setResolution(160, 50)
  733. for k,v in pairs(Events) do
  734. print("Canceling Event Listener: "..k) -- For debug
  735. event.cancel(v)
  736. end
  737. io.stderr:write(ErrorMessage.."\n")
  738. -- End of program -----------------------------------------
Add Comment
Please, Sign In to add comment