Advertisement
MrDionesalvi

Rich

Nov 15th, 2020 (edited)
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.94 KB | None | 0 0
  1. local maxw, maxh = term.getSize()
  2.  
  3. lato = "bottom"
  4.  
  5. soldi = 2000000
  6.  
  7. rs.setOutput(lato, true)
  8.  
  9.  
  10. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  11. local function drawPixelInternal(xPos, yPos)
  12.     term.setCursorPos(xPos, yPos)
  13.     term.write(" ")
  14. end
  15.  
  16. local tColourLookup = {}
  17. for n = 1, 16 do
  18.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  19. end
  20.  
  21. function drawFilledBox(startX, startY, endX, endY, nColour)
  22.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  23.         "number" or type(endY) ~= "number" or
  24.         (nColour ~= nil and type(nColour) ~= "number") then
  25.         error("Expected startX, startY, endX, endY, colour", 2)
  26.     end
  27.  
  28.     startX = math.floor(startX)
  29.     startY = math.floor(startY)
  30.     endX = math.floor(endX)
  31.     endY = math.floor(endY)
  32.  
  33.     if nColour then term.setBackgroundColor(nColour) end
  34.     if startX == endX and startY == endY then
  35.         drawPixelInternal(startX, startY)
  36.         return
  37.     end
  38.  
  39.     local minX = math.min(startX, endX)
  40.     if minX == startX then
  41.         minY = startY
  42.         maxX = endX
  43.         maxY = endY
  44.     else
  45.         minY = endY
  46.         maxX = startX
  47.         maxY = startY
  48.     end
  49.  
  50.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  51. end
  52.  
  53. function colore(nome) term.setTextColor(nome) end
  54.  
  55. function sfondo(nome) term.setBackgroundColor(nome) end
  56.  
  57. function fineColore() term.setTextColour(colours.white) end
  58.  
  59. function fineSfondo() term.setBackgroundColour(colours.black) end
  60.  
  61. function titolo(testo)
  62.     drawFilledBox(1, 1, maxw, 1, colors.blue)
  63.     term.setCursorPos((maxw - #testo) / 2, 1)
  64.     colore(colors.white)
  65.     term.write(testo)
  66.     sfondo(colors.white)
  67. end
  68.  
  69. function clear()
  70.     sfondo(colors.blue)
  71.     term.clear()
  72.     term.setCursorPos(1, 1)
  73. end
  74.  
  75. function errore(errore)
  76.     sfondo(colors.red)
  77.     colore(colors.white)
  78.     term.clear()
  79.     term.setCursorPos(1, 1)
  80.     titolo("Errore irreversibile")
  81.     term.setCursorPos(1, 3)
  82.     sfondo(colors.red)
  83.     colore(colors.white)
  84.     term.setCursorPos(16, 10)
  85.     term.write("Sei un poraccio...")
  86.     os.sleep(5)
  87.     os.reboot()
  88. end
  89.  
  90. clear()
  91. sfondo(colors.lightBlue)
  92. colore(colors.black)
  93. term.setCursorPos(1, 1)
  94. titolo("RICHBICH")
  95. term.setCursorPos(1, 3)
  96.  
  97.  
  98. drawFilledBox(18, 9, 31, 11, colors.white)
  99. colore(colors.red)
  100. term.setCursorPos(20, 10)
  101. term.write("Login RICH")
  102. drawFilledBox(18, 13, 31, 15, colors.white)
  103. term.setCursorPos(19, 14)
  104. term.write("Login P-RICH")
  105.  
  106.  
  107. while true do
  108.     local event, par1, par2, par3 = os.pullEvent("mouse_click")
  109.     if par2 >= 20 and par2 <= 27 and par3 >= 10 and par3 <= 12 then -- Utenti
  110.  
  111.         clear()
  112.         term.clear()
  113.         fineSfondo()
  114.         titolo("LOGIN MTF RICH")
  115.         sfondo(colors.lightBlue)
  116.         colore(colors.white)
  117.         term.setCursorPos(1, 3)
  118.         print("Inserire i propri dati.")
  119.         colore(colors.gray)
  120.         print("\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventerà verde.\nSe sono errati, il programma chiederà di reinserirli nuovamente.")
  121.  
  122.         --nomeutente
  123.         term.setCursorPos(1, 10)
  124.         colore(colors.black)
  125.         term.write("Nome utente:")
  126.         term.setCursorPos(15, 10)
  127.         colore(colors.white)
  128.         utenteAccettato = false
  129.         conteggioErrori = 0
  130.         while utenteAccettato == false do
  131.             utente = read()
  132.             checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
  133.             tabcheckuser = textutils.unserialize(checkuser)
  134.             if tabcheckuser.stato == "OK" then
  135.                 term.setCursorPos(15, 10)
  136.                 colore(colors.lime)
  137.                 term.write(utente)
  138.                 colore(colors.white)
  139.                 utenteAccettato = true
  140.             else
  141.                 term.setCursorPos(15, 10)
  142.                 colore(colors.red)
  143.                 term.write("Utente errato!")
  144.                 sleep(2)
  145.                 term.setCursorPos(15, 10)
  146.                 colore(colors.white)
  147.                 term.write("                       ")
  148.                 term.setCursorPos(15, 10)
  149.                 conteggioErrori = conteggioErrori + 1
  150.                 if conteggioErrori > 2 then
  151.                     term.setCursorPos(15, 10)
  152.                     colore(colors.red)
  153.                     term.write("Tre tentativi di immissione errati.")
  154.                     sleep(2)
  155.                     term.setCursorPos(15, 10)
  156.                     colore(colors.white)
  157.                     term.write("                       ")
  158.                     term.setCursorPos(15, 10)
  159.                     clear()
  160.                     os.reboot()
  161.                 end
  162.             end
  163.         end
  164.  
  165.         --password
  166.         colore(colors.black)
  167.         term.setCursorPos(1,12)
  168.         term.write("Password:")
  169.         term.setCursorPos(15, 12)
  170.          
  171.         conteggioErrori = 0
  172.         passAccettata = false
  173.         while passAccettata == false do
  174.             colore(colors.white)
  175.             password = read("#")
  176.             colore(colors.black)
  177.             checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
  178.             risposta = textutils.unserialize(checkuser)
  179.             if risposta.stato == "OK" then
  180.                 term.setCursorPos(15, 12)
  181.                 colore(colors.lime)
  182.                 term.write("##############")
  183.                 colore(colors.white)
  184.                 passAccettata = true
  185.                 else
  186.                     term.setCursorPos(15, 12)
  187.                     colore(colors.red)
  188.                     term.write("Password errata!")
  189.                     conteggioErrori = conteggioErrori + 1
  190.                     sleep(2)
  191.                     term.setCursorPos(15, 12)
  192.                     term.write("                       ")
  193.                     term.setCursorPos(15, 12)
  194.                 if conteggioErrori > 2 then
  195.                     term.setCursorPos(15, 12)
  196.                     colore(colors.red)
  197.                     term.write("Tre tentativi di immissione errati.")
  198.                     sleep(2)
  199.                     term.setCursorPos(15, 12)
  200.                     term.write("                       ")
  201.                     term.setCursorPos(15, 12)
  202.                     clear()
  203.                     os.reboot()
  204.                 end
  205.             end
  206.         end
  207.        
  208.         while true do
  209.  
  210.             --Ricontrolla il saldo per gestire l'aggiornamento di piåA5B9 operazioni
  211.             checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
  212.             risposta = textutils.unserialize(checkuser)
  213.             saldo = tonumber(risposta.saldo)
  214.             --Disegna la finestra del pannello utente
  215.             clear()
  216.             titolo("Pannello utente RICHBICH")
  217.             sfondo(colors.lightBlue)
  218.             colore(colors.black)
  219.             term.setCursorPos(1, 3)
  220.             term.write("Benvenuto, ")
  221.             colore(colors.white)
  222.             term.write(utente)
  223.             colore(colors.black)
  224.             term.write("!         Saldo: ")
  225.             colore(colors.white)
  226.             term.write(saldo)
  227.             colore(colors.black)
  228.             term.write(" IC")
  229.             print("\n\nOperazioni disponibili:\n")
  230.             sfondo(colors.lightBlue)
  231.             colore(colors.white)
  232.             print(" Apri porta RICH  \n")
  233.             print(" Donazione RICH \n")
  234.             colore(colors.red)
  235.             print(" Disconnettiti da RICH  \n")
  236.             colore(colors.black)
  237.  
  238.             antitonto = os.startTimer(60)
  239.  
  240.             event, key, x, y = os.pullEventRaw()
  241.             if event == "mouse_click" and y == 7 and x <= 24 then       --Pulsante carica denaro su nPay
  242.                 clear()
  243.                 titolo("Apertura porta RICH")
  244.                 if(saldo>=soldi) then
  245.                    
  246.                     rs.setOutput(lato, false)
  247.                     sleep(3)
  248.                     os.reboot()
  249.  
  250.                 else
  251.            
  252.                     inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. "10" .. "&beneficiario=" .. "calafricagroup").readAll()
  253.                     risultatoInvio = textutils.unserialize(inviaDenaro)
  254.                     if risultatoInvio.stato == "OK" then
  255.                         term.setCursorPos(1, 10)
  256.                         colore(colors.red)
  257.                         term.write("Soldi scalati ;)")
  258.                     else
  259.                         term.setCursorPos(1, 10)
  260.                         colore(colors.red)
  261.                         term.write("Che culo :(")
  262.                     end
  263.                     sleep(1)
  264.                     errore("poraccio")
  265.                 end
  266.  
  267.             else if event == "mouse_click" and y == 11 and x <= 31 then
  268.                 os.sleep(1)
  269.                 os.reboot()
  270.  
  271.             end
  272.  
  273.             end
  274.  
  275.  
  276.         end
  277.  
  278.     else if par2 >= 19 and par2 <= 26 and par3 >= 13 and par3 <= 15 then
  279.         while true do
  280.             clear()
  281.             titolo("Apertura porta RICH")
  282.             testo = "Bucchi metti la mano sopra :)"
  283.             term.setCursorPos((maxw - #testo) / 2, 12)
  284.             colore(colors.black)
  285.             term.write("Bucchi metti la mano sopra :)")
  286.  
  287.             antitonto = os.startTimer(5)
  288.             event, playerName = os.pullEvent()
  289.             if event == "player" and playerName == "dionesalvi" or playerName == "kiiw" then
  290.  
  291.                 clear()
  292.                 titolo("Apertura porta RICH")
  293.                 rs.setOutput(lato, false)
  294.                 sleep(3)
  295.                 os.reboot()
  296.  
  297.             end
  298.             os.reboot()
  299.  
  300.         end
  301.  
  302.     end
  303.  
  304.  
  305.     end
  306. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement