Advertisement
MrDionesalvi

TripAdvisor

Nov 2nd, 2020 (edited)
2,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.81 KB | None | 0 0
  1. -- TrusPilot by CFG in collaborazione con Artemis
  2.  
  3. local maxw, maxh = term.getSize()
  4.  
  5.  
  6. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  7. local function drawPixelInternal(xPos, yPos)
  8.     term.setCursorPos(xPos, yPos)
  9.     term.write(" ")
  10. end
  11.  
  12. local tColourLookup = {}
  13. for n = 1, 16 do
  14.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  15. end
  16.  
  17. function drawFilledBox(startX, startY, endX, endY, nColour)
  18.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  19.         "number" or type(endY) ~= "number" or
  20.         (nColour ~= nil and type(nColour) ~= "number") then
  21.         error("Expected startX, startY, endX, endY, colour", 2)
  22.     end
  23.  
  24.     startX = math.floor(startX)
  25.     startY = math.floor(startY)
  26.     endX = math.floor(endX)
  27.     endY = math.floor(endY)
  28.  
  29.     if nColour then term.setBackgroundColor(nColour) end
  30.     if startX == endX and startY == endY then
  31.         drawPixelInternal(startX, startY)
  32.         return
  33.     end
  34.  
  35.     local minX = math.min(startX, endX)
  36.     if minX == startX then
  37.         minY = startY
  38.         maxX = endX
  39.         maxY = endY
  40.     else
  41.         minY = endY
  42.         maxX = startX
  43.         maxY = startY
  44.     end
  45.  
  46.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  47. end
  48.  
  49. function colore(nome) term.setTextColor(nome) end
  50.  
  51. function sfondo(nome) term.setBackgroundColor(nome) end
  52.  
  53. function fineColore() term.setTextColour(colours.white) end
  54.  
  55. function fineSfondo() term.setBackgroundColour(colours.black) end
  56.  
  57. function titolo(testo)
  58.     drawFilledBox(1, 1, maxw, 1, colors.blue)
  59.     term.setCursorPos((maxw - #testo) / 2, 1)
  60.     colore(colors.white)
  61.     term.write(testo)
  62.     sfondo(colors.white)
  63. end
  64.  
  65. function clear()
  66.     sfondo(colors.blue)
  67.     term.clear()
  68.     term.setCursorPos(1, 1)
  69. end
  70.  
  71. function errore(errore)
  72.     sfondo(colors.red)
  73.     colore(colors.white)
  74.     term.clear()
  75.     term.setCursorPos(1, 1)
  76.     titolo("Errore irreversibile")
  77.     term.setCursorPos(1, 3)
  78.     sfondo(colors.red)
  79.     colore(colors.white)
  80.     term.write(errore)
  81.     term.write("\n\n\nAttendere qualche secondo...")
  82.     os.sleep(5)
  83.     os.reboot()
  84. end
  85.  
  86. clear()
  87.  
  88. term.setCursorPos(1, 1)
  89. titolo("Trust Pilot")
  90. term.setCursorPos(1, 3)
  91. colore(colors.white)
  92. sfondo(colors.lime)
  93. term.setCursorPos(10, 10)
  94. term.write("Login Utente")
  95. term.setCursorPos(31, 11)
  96. term.write("")
  97. term.setCursorPos(31, 10)
  98. term.write("Login Aziendale")
  99. while true do
  100.     local event, par1, par2, par3 = os.pullEvent("mouse_click")
  101.     if par2 >= 10 and par2 <= 26 and par3 >= 10 and par3 <= 12 then -- Utenti
  102.  
  103.         clear()
  104.         titolo("TrustPilot Login Utente")
  105.  
  106.     elseif par2 >= 31 and par2 <= 46 and par3 >= 10 and par3 <= 12 then -- Aziende
  107.         clear()
  108.         titolo("TrustPilot Login Azienda")
  109.  
  110.     end
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement