Advertisement
lego11

Setup NAudioSystem

May 28th, 2023 (edited)
994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. local maxw, maxh = term.getSize()
  2. function clear()
  3.     term.clear()
  4.     term.setCursorPos(1, 1)
  5.     term.setBackgroundColour(colours.black)
  6.     term.setTextColor(colors.white)
  7. end
  8. function colore(sfumatura) term.setTextColour(sfumatura) end
  9. function fineColore() term.setTextColour(colours.white) end
  10. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  11. function fineSfondo() term.setBackgroundColour(colours.black) end
  12.  
  13. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  14. local function drawPixelInternal(xPos, yPos)
  15.     term.setCursorPos(xPos, yPos)
  16.     term.write(" ")
  17. end
  18. local tColourLookup = {}
  19. for n = 1, 16 do
  20.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  21. end
  22. function drawFilledBox(startX, startY, endX, endY, nColour)
  23.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  24.         "number" or type(endY) ~= "number" or
  25.         (nColour ~= nil and type(nColour) ~= "number") then
  26.         error("Expected startX, startY, endX, endY, colour", 2)
  27.     end
  28.  
  29.     startX = math.floor(startX)
  30.     startY = math.floor(startY)
  31.     endX = math.floor(endX)
  32.     endY = math.floor(endY)
  33.  
  34.     if nColour then term.setBackgroundColor(nColour) end
  35.     if startX == endX and startY == endY then
  36.         drawPixelInternal(startX, startY)
  37.         return
  38.     end
  39.  
  40.     local minX = math.min(startX, endX)
  41.     if minX == startX then
  42.         minY = startY
  43.         maxX = endX
  44.         maxY = endY
  45.     else
  46.         minY = endY
  47.         maxX = startX
  48.         maxY = startY
  49.     end
  50.  
  51.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  52. end
  53.  
  54. function titolo(testo)
  55.     drawFilledBox(1, 1, maxw, 1, colors.red)
  56.     term.setCursorPos((maxw - #testo) / 2, 1)
  57.     colore(colors.white)
  58.     term.write(testo)
  59.     sfondo(colors.blue)
  60. end
  61. while true do
  62. sfondo(colors.blue)
  63. clear()
  64. titolo("Installazione N AUDIO SYSTEM")
  65. print("\n\n")
  66. print("Si sta eseguendo GEM su questo computer?")
  67. print("\n1. Si\n2. No\n")
  68. local isGem = read()
  69. if isGem == "1" then
  70. shell.run("rm /programs/icons/NPlayer")
  71. shell.run("rm /programs/NPlayer")
  72. shell.run("pastebin get Ei4HDiwy /programs/icons/NPlayer")
  73. shell.run("pastebin get TyTyYRQd /programs/NPlayer")
  74. clear()
  75. titolo("Installazione N AUDIO SYSTEM")
  76. print("\n\n")
  77. print("Installazione completata. Rimuovere il disco.")
  78. os.pullEvent("disk_eject")
  79. os.reboot()
  80. elseif isGem == "2" then
  81. shell.run("pastebin get TyTyYRQd /NPlayer")
  82. clear()
  83. titolo("Installazione N AUDIO SYSTEM")
  84. print("\n\n")
  85. print("Installazione completata.\nPer eseguire N Audio System, digitare nel terminale:\nnplayer\nRimuovere il disco.")
  86. os.pullEvent("disk_eject")
  87. os.reboot()
  88. else
  89. clear()
  90. titolo("Installazione N AUDIO SYSTEM")
  91. print("\n\n")
  92. print("Scelta non valida")
  93. sleep(1)
  94. end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement