lego11

Installer GEM

Sep 25th, 2020 (edited)
920
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local maxw, maxh = term.getSize()
  2.  
  3. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  4. local function drawPixelInternal(xPos, yPos)
  5.     term.setCursorPos(xPos, yPos)
  6.     term.write(" ")
  7. end
  8.  
  9. local tColourLookup = {}
  10. for n = 1, 16 do
  11.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  12. end
  13.  
  14. function drawFilledBox(startX, startY, endX, endY, nColour)
  15.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  16.         "number" or type(endY) ~= "number" or
  17.         (nColour ~= nil and type(nColour) ~= "number") then
  18.         error("Expected startX, startY, endX, endY, colour", 2)
  19.     end
  20.  
  21.     startX = math.floor(startX)
  22.     startY = math.floor(startY)
  23.     endX = math.floor(endX)
  24.     endY = math.floor(endY)
  25.  
  26.     if nColour then term.setBackgroundColor(nColour) end
  27.     if startX == endX and startY == endY then
  28.         drawPixelInternal(startX, startY)
  29.         return
  30.     end
  31.  
  32.     local minX = math.min(startX, endX)
  33.     if minX == startX then
  34.         minY = startY
  35.         maxX = endX
  36.         maxY = endY
  37.     else
  38.         minY = endY
  39.         maxX = startX
  40.         maxY = startY
  41.     end
  42.  
  43.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  44. end
  45.  
  46. function clear()
  47.     sfondo(colors.blue)
  48.     term.clear()
  49.     term.setCursorPos(1, 1)
  50. end
  51.  
  52. function fineColore() term.setTextColour(colours.white) end
  53.  
  54. function fineSfondo() term.setBackgroundColour(colours.black) end
  55.  
  56. function colore(sfumatura) term.setTextColour(sfumatura) end
  57.  
  58. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  59.  
  60. function titolo(testo)
  61.     drawFilledBox(1, 1, maxw, 1, colors.red)
  62.     term.setCursorPos((maxw - #testo) / 2, 1)
  63.     colore(colors.black)
  64.     term.write(testo)
  65.     sfondo(colors.blue)
  66. end
  67.  
  68. clear()
  69. titolo("Installazione di GEM")
  70. colore(colors.white)
  71. sfondo(colors.blue)
  72. print("\n\nBenvenuti nel programma di installazione di GEM.")
  73. print("\nPer continuare l'installazione, inserire un nome per questo computer.")
  74. print("Lasciare il campo vuoto per sceglierlo automaticamente.\n")
  75.  
  76. local label = read()
  77.  
  78. if label ~= "" or label ~= nil then
  79.     os.setComputerLabel("GemPC-"..tostring(label))
  80. end
  81.  
  82. shell.run("pastebin get dG1EZ5js startup")
  83.  
  84. disk.eject("bottom")
  85. disk.eject("top")
  86. disk.eject("left")
  87. disk.eject("right")
  88. os.reboot()
RAW Paste Data