Advertisement
lego11

SKINBOX

Jul 16th, 2020 (edited)
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.18 KB | None | 0 0
  1. local maxw, maxh = term.getSize()
  2.  
  3. function clear()
  4.     term.clear()
  5.     term.setCursorPos(1, 1)
  6. end
  7.  
  8. function clearRed()
  9.     sfondo(colors.red)
  10.     term.clear()
  11.     term.setCursorPos(1, 1)
  12. end
  13.  
  14. function colore(sfumatura) term.setTextColour(sfumatura) end
  15.  
  16. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  17.  
  18. function fineColore() term.setTextColour(colours.white) end
  19.  
  20. function fineSfondo() term.setBackgroundColour(colours.black) end
  21.  
  22.  
  23. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  24. local function drawPixelInternal(xPos, yPos)
  25.     term.setCursorPos(xPos, yPos)
  26.     term.write(" ")
  27. end
  28.  
  29. local tColourLookup = {}
  30. for n = 1, 16 do
  31.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  32. end
  33.  
  34. function drawFilledBox(startX, startY, endX, endY, nColour)
  35.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  36.         "number" or type(endY) ~= "number" or
  37.         (nColour ~= nil and type(nColour) ~= "number") then
  38.         error("Expected startX, startY, endX, endY, colour", 2)
  39.     end
  40.  
  41.     startX = math.floor(startX)
  42.     startY = math.floor(startY)
  43.     endX = math.floor(endX)
  44.     endY = math.floor(endY)
  45.  
  46.     if nColour then term.setBackgroundColor(nColour) end
  47.     if startX == endX and startY == endY then
  48.         drawPixelInternal(startX, startY)
  49.         return
  50.     end
  51.  
  52.     local minX = math.min(startX, endX)
  53.     if minX == startX then
  54.         minY = startY
  55.         maxX = endX
  56.         maxY = endY
  57.     else
  58.         minY = endY
  59.         maxX = startX
  60.         maxY = startY
  61.     end
  62.  
  63.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  64. end
  65.  
  66.  
  67. function titolo(testo)
  68.     drawFilledBox(1, 1, maxw, 1, colors.yellow)
  69.     term.setCursorPos((maxw - #testo) / 2, 1)
  70.     colore(colors.black)
  71.     term.write(testo)
  72.     term.setBackgroundColor(colors.black)
  73.     colore(colors.white)
  74. end
  75.  
  76. function errore(errore)
  77.     sfondo(colors.red)
  78.     colore(colors.white)
  79.     term.clear()
  80.     term.setCursorPos(1, 1)
  81.     titolo("Errore irreversibile")
  82.     term.setCursorPos(1, 3)
  83.     sfondo(colors.red)
  84.     colore(colors.white)
  85.     print(errore)
  86.     print("\n\n\nAttendere qualche secondo...")
  87.     os.sleep(5)
  88.     os.reboot()
  89. end
  90.  
  91. clear()
  92. titolo("MINISTERO DELL'ABBODANZA")
  93. print("\n\nRitiro premio giornaliero per VOTO SERVER")
  94. print("")
  95. print("Dopo aver votato il server su MineAlpha, ritira il premio su questo computer.")
  96. print("")
  97. colore(colors.orange)
  98. print("PER RITIRARE IL PREMIO:")
  99. print("Fare clic DESTRO sul sensore sottostante")
  100. local event, player = os.pullEvent()
  101.  
  102.     sfondo(colours.blue)
  103.     term.clear()
  104.     term.setCursorPos(1, 1)
  105.     titolo("Autenticati con Nebraska Pay")
  106.     sfondo(colours.blue)
  107.     colore(colors.white)
  108.     print(
  109.         "\n\nInserire i propri dati (non verrà effettuato alcun addebito). Premere Enter per confermare i dati inseriti. \nSe i dati sono errati, il programma chiederà di reinserirli nuovamente.")
  110.  
  111.     -- nomeutente
  112.     term.setCursorPos(1, 9)
  113.     term.write("Nome utente:")
  114.     term.setCursorPos(15, 9)
  115.     fineColore()
  116.     utenteAccettato = false
  117.     conteggioErrori = 0
  118.     while utenteAccettato == false do
  119.         utente = read()
  120.         utente = string.gsub(utente, "%s", "")
  121.         checkuser = http.get(
  122.                         "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" ..
  123.                             utente).readAll()
  124.         tabcheckuser = textutils.unserialize(checkuser)
  125.         if tabcheckuser.stato == "OK" then
  126.             term.setCursorPos(15, 9)
  127.             colore(colours.lime)
  128.             term.write(utente)
  129.             fineColore()
  130.             utenteAccettato = true
  131.         else
  132.             term.setCursorPos(15, 9)
  133.             colore(colours.red)
  134.             term.write("Utente errato!          ")
  135.             sleep(2)
  136.             term.setCursorPos(15, 9)
  137.             fineColore()
  138.             term.write("                       ")
  139.             term.setCursorPos(15, 9)
  140.             conteggioErrori = conteggioErrori + 1
  141.             if conteggioErrori > 2 then
  142.                 term.setCursorPos(15, 9)
  143.                 colore(colours.red)
  144.                 errore("Troppi tentativi di immissione errati    ")
  145.             end
  146.         end
  147.     end
  148.     colore(colours.white)
  149.     term.setCursorPos(1, 11)
  150.     term.write("Password:")
  151.     term.setCursorPos(15, 11)
  152.     conteggioErrori = 0
  153.     passAccettata = false
  154.     while passAccettata == false do
  155.         fineColore()
  156.         password = read("#")
  157.         colore(colours.black)
  158.         checkuser = http.get(
  159.                         "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" ..
  160.                             password .. "&richiesta=addebito&valore=0&utente=" ..
  161.                             utente).readAll()
  162.         risposta = textutils.unserialize(checkuser)
  163.         if risposta.stato == "OK" then
  164.             term.setCursorPos(15, 11)
  165.             colore(colours.lime)
  166.             term.write("##############               ")
  167.             fineColore()
  168.             passAccettata = true
  169.         else
  170.             term.setCursorPos(15, 11)
  171.             colore(colours.red)
  172.             term.write("Password errata!            ")
  173.             conteggioErrori = conteggioErrori + 1
  174.             sleep(2)
  175.             term.setCursorPos(15, 11)
  176.             term.write("                               ")
  177.             term.setCursorPos(15, 11)
  178.             if conteggioErrori > 2 then
  179.                 term.setCursorPos(15, 11)
  180.                 colore(colours.red)
  181.                 errore("Troppi tentativi di immissione errati")
  182.             end
  183.         end
  184.     end
  185.    
  186. local checkRaw = http.get("http://172.16.20.220/luanet/servlets/votesystem/?user=" .. player).readAll()
  187. check = textutils.unserialize(checkRaw)
  188.  
  189. if check.stato == "EA" then
  190.     errore(check.errore)
  191. end
  192.  
  193. print(checkRaw)
  194. error(event)
  195.  
  196. sfondo(colors.black)
  197. colore(colors.lime)
  198. term.clear()
  199. term.setCursorPos(1, 1)
  200. titolo("Ordini consegnati")
  201. term.setCursorPos(1, 3)
  202. sfondo(colors.black)
  203. colore(colors.lime)
  204. print("\n\n\nAttendere qualche secondo per l'erogazione di tutti gli ordini...")
  205. os.sleep(5)
  206. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement