Advertisement
pepeknamornik

OLD Media player

Dec 22nd, 2020
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 KB | None | 0 0
  1. local w,h = term.getSize()
  2.  
  3. local f=fs.open("/C/system/RAM/user","r")
  4. user=f.readLine()
  5. f.close()
  6.  
  7. if fs.exists("/C/system/Users/"..user.."/colors") then
  8.     nastaveni={barva=colors.blue}
  9.     f=fs.open("/C/system/Users/"..user.."/colors","r")
  10.     cnt=f.readAll()
  11.     f.close()
  12.     nastaveni=textutils.unserialize(cnt)    
  13.     f=fs.open("/C/system/Users/"..user.."/textcol","r")
  14.     tnt=f.readAll()
  15.     f.close()
  16.     text=textutils.unserialize(tnt)
  17. else
  18.     f=fs.open("/C/system/.core/colors","r")
  19.     cnt=f.readAll()
  20.     f.close()
  21.     nastaveni=textutils.unserialize(cnt)
  22.     f=fs.open("/C/system/.core/textcol","r")
  23.     tnt=f.readAll()
  24.     f.close()
  25.     text=textutils.unserialize(tnt)
  26. end
  27.  
  28. local function prc(text, y)
  29.   local w = term.getSize()
  30.   local _, cy = term.getCursorPos()
  31.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  32.   write(text)
  33. end
  34.  
  35. function prehravac ()
  36. term.setBackgroundColor(colors.white)
  37. term.setTextColor(colors.black)
  38. term.clear()
  39. term.setCursorPos(1,1)
  40. term.setBackgroundColor(nastaveni.barva)
  41. term.setTextColor(colors.white)
  42. print "                                                   "
  43. term.setCursorPos(19,1)
  44. prc ("Media Player")
  45. term.setTextColor(colors.black)
  46.  
  47. term.setCursorPos(5,8)
  48. term.setBackgroundColor(colors.yellow)
  49. term.setTextColor(colors.black)
  50. print" Play "
  51. term.setCursorPos(41,8)
  52. print" Stop "
  53. paintutils.drawPixel(51, 1, colors.red)
  54. term.setTextColor(colors.white)
  55. term.setCursorPos(51, 1)
  56. print "Q"
  57.  
  58.  
  59.  
  60.     while true do
  61.     local event, button, x, y = os.pullEvent("mouse_click")
  62.     xy = x..","..y
  63.  
  64.     if xy == "51,1" and button == 1 then
  65.     error()
  66.     break
  67.     end
  68.  
  69.     if xy == "6,8" and button == 1 then
  70.     disk.playAudio("left")
  71.     disk.playAudio("right")
  72.     disk.playAudio("bottom")
  73.     prehravac ()
  74.     break
  75.     end
  76.  
  77.     if xy == "7,8" and button == 1 then
  78.     disk.playAudio("left")
  79.     disk.playAudio("right")
  80.     disk.playAudio("bottom")
  81.     prehravac ()
  82.     break
  83.     end
  84.  
  85.     if xy == "8,8" and button == 1 then
  86.     disk.playAudio("left")
  87.     disk.playAudio("right")
  88.     disk.playAudio("bottom")
  89.     prehravac ()
  90.     break
  91.     end
  92.  
  93.     if xy == "9,8" and button == 1 then
  94.     disk.playAudio("left")
  95.     disk.playAudio("right")
  96.     disk.playAudio("bottom")
  97.     prehravac ()
  98.     break
  99.     end
  100.  
  101.     if xy == "10,8" and button == 1 then
  102.     disk.playAudio("left")
  103.     disk.playAudio("right")
  104.     disk.playAudio("bottom")
  105.     prehravac ()
  106.     break
  107.     end
  108.  
  109.     if xy == "11,8" and button == 1 then
  110.     disk.playAudio("left")
  111.     disk.playAudio("right")
  112.     disk.playAudio("bottom")
  113.     prehravac ()
  114.     break
  115.     end
  116.  
  117.     if xy == "12,8" and button == 1 then
  118.     disk.playAudio("left")
  119.     disk.playAudio("right")
  120.     disk.playAudio("bottom")
  121.     prehravac ()
  122.     break
  123.     end
  124.  
  125.     if xy == "45,8" and button == 1 then
  126.     print("Stop")
  127.     disk.stopAudio("left")
  128.     disk.stopAudio("right")
  129.     disk.stopAudio("bottom")
  130.     prehravac ()
  131.     break
  132.     end
  133.  
  134.     if xy == "42,8" and button == 1 then
  135.     print("Stop")
  136.     disk.stopAudio("left")
  137.     disk.stopAudio("right")
  138.     disk.stopAudio("bottom")
  139.     prehravac ()
  140.     break
  141.     end
  142.  
  143.     if xy == "43,8" and button == 1 then
  144.     print("Stop")
  145.     disk.stopAudio("left")
  146.     disk.stopAudio("right")
  147.     disk.stopAudio("bottom")
  148.     prehravac ()
  149.     break
  150.     end
  151.  
  152.     if xy == "44,8" and button == 1 then
  153.     print("Stop")
  154.     disk.stopAudio("left")
  155.     disk.stopAudio("right")
  156.     disk.stopAudio("bottom")
  157.     prehravac ()
  158.     break
  159.     end
  160.    
  161.     end
  162. end
  163.  
  164. prehravac ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement