Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local maxw, maxh = term.getSize()
- --IMPLEMENTAZIONE DEL DRAWFILLEDBOX
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1,16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2^(n-1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or
- type(endX) ~= "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then
- term.setBackgroundColor(nColour)
- end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do
- for y = minY, maxY do
- drawPixelInternal(x, y)
- end
- end
- end
- function clear()
- sfondo(colors.lightBlue)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function colore(sfumatura)
- term.setTextColour(sfumatura)
- end
- function sfondo(sfumaturaSfondo)
- term.setBackgroundColour(sfumaturaSfondo)
- end
- function titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.yellow)
- term.setCursorPos((maxw - #testo) / 2, 1)
- colore(colors.black)
- term.write(testo)
- sfondo(colors.lightBlue)
- end
- function update()
- term.setCursorPos(1, 21)
- shell.run("pastebin get y1AP0iNY startup2") -- Inserire paste di nPay
- if fs.exists("startup2") then
- shell.run("rm startup")
- shell.run("mv startup2 startup")
- end
- os.reboot()
- end
- function disconnetti()
- clear()
- text = "ARRIVEDERCI!"
- colore(colors.white)
- term.setCursorPos((maxw - #text) / 2, math.floor(maxh / 2))
- term.write(text)
- colore(colors.black)
- text2 = "Tra poco saråA0 possibile eseguire"
- text3 = "una nuova operazione..."
- term.setCursorPos((maxw - #text2) / 2, math.floor(maxh / 2) + 2)
- print(text2)
- term.setCursorPos((maxw - #text3) / 2, math.floor(maxh / 2) + 3)
- print(text3)
- os.sleep(0.5)
- update()
- end
- function drawCard()
- drawFilledBox(6, 7, 24, 7, colors.blue)
- drawFilledBox(6, 15, 24, 15, colors.blue)
- drawFilledBox(5, 8, 25, 14, colors.blue)
- drawFilledBox(7, 9, 23, 9, colors.lightGray)
- drawFilledBox(7, 12, 23, 13, colors.black)
- end
- mag = peripheral.wrap("bottom")
- bl = "BN Credit"
- sfondo(colors.lightBlue)
- clear()
- colore(colors.white)
- print(" ")
- print(" ___ ")
- print(" _ __ / _ \\__ _ _ _ ")
- print(" | '_ \\ / /_)/ _ | | | |")
- print(" | | | / ___/ (_| | |_| |")
- print(" |_| |_\\/ \\__,_|\\__, |")
- print(" |___/ ")
- -- Bottoni login/registrati
- drawFilledBox(14, 10, 38, 12, colors.white)
- term.setCursorPos(23, 11)
- colore(colors.black)
- term.write("Accedi")
- drawFilledBox(14, 15, 38, 17, colors.white)
- term.setCursorPos(21, 16)
- colore(colors.black)
- term.write("Sei nuovo?")
- while true do
- event, key, x, y = os.pullEvent("mouse_click")
- if event == "mouse_click" and x >= 14 and x <= 38 and y >= 15 and y <= 17 then
- -- Registrazione nuovo utente
- clear()
- titolo("Registrati a nPay")
- term.setCursorPos(1, 3)
- print("Inserisci un nome utente e una password sicura.")
- term.setCursorPos(1, 5)
- colore(colors.gray)
- print("Premi ENTER per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA0 verde.\nSe sono errati, il programma chiederåA0 di reinserirli nuovamente.")
- -- Nome Utente
- term.setCursorPos(1, 10)
- colore(colors.black)
- term.write("Nome utente:")
- term.setCursorPos(14, 10)
- colore(colors.white)
- utenteAccettato = false
- conteggioErrori = 0
- while utenteAccettato == false do
- utente = read()
- utente = string.gsub(utente, "%s", "")
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
- tabcheckuser = textutils.unserialize(checkuser)
- if tabcheckuser.stato == "NO" then
- term.setCursorPos(14, 10)
- colore(colors.lime)
- term.write(utente)
- colore(colors.white)
- utenteAccettato = true
- else
- term.setCursorPos(14, 10)
- colore(colors.red)
- term.write("Utente giåA0 esistente!")
- sleep(2)
- term.setCursorPos(14, 10)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(14, 10)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(14, 10)
- colore(colors.red)
- term.write("Tre tentativi di immissione errati.")
- sleep(2)
- term.setCursorPos(14, 10)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(14, 10)
- clear()
- os.reboot()
- end
- end
- end
- --password
- colore(colors.black)
- term.setCursorPos(1, 12)
- term.write("Password:")
- term.setCursorPos(11, 12)
- colore(colors.white)
- passAccettata = false
- conteggioErrori = 0
- while passAccettata == false do
- password1 = read("#")
- colore(colors.black)
- term.setCursorPos(1, 13)
- term.write("Verifica:")
- term.setCursorPos(11, 13)
- colore(colors.white)
- local password2 = read("#")
- if password1 == password2 then
- term.setCursorPos(11, 12)
- colore(colors.lime)
- term.write("###############")
- term.setCursorPos(11, 13)
- term.write("###############")
- colore(colors.white)
- passAccettata = true
- else
- colore(colors.red)
- term.setCursorPos(11, 12)
- term.write("Le password non corrispondono! ")
- term.setCursorPos(1, 13)
- colore(colors.white)
- term.write(" ")
- sleep(1.5)
- term.setCursorPos(11, 12)
- term.write(" ")
- term.setCursorPos(11, 12)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(14, 12)
- colore(colors.red)
- term.write("Tre tentativi di immissione errati.")
- sleep(1.5)
- term.setCursorPos(14, 12)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(14, 12)
- clear()
- os.reboot()
- end
- end
- end
- --crea l'account
- term.setCursorPos(1, 17)
- creaAccount = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password1 .. "&utente=" .. utente .. "&richiesta=crea&valore=0").readAll()
- tabCreaAccount = textutils.unserialize(creaAccount)
- if tabCreaAccount.stato == "OA" then
- colore(colors.lime)
- print("Conto creato con successo.")
- sleep(1.5)
- clear()
- os.reboot()
- else
- colore(colors.red)
- print("Errore durante la creazione del conto.")
- sleep(1.5)
- clear()
- os.reboot()
- end
- elseif event == "mouse_click" and x >= 14 and x <= 38 and y >= 10 and y <= 12 then
- clear()
- titolo("Accedi a nPay")
- term.setCursorPos(1, 3)
- colore(colors.black)
- print("Inserire i propri dati.")
- colore(colors.gray)
- print("\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA0 verde.\nSe sono errati, il programma chiederåA0 di reinserirli nuovamente.")
- --nomeutente
- term.setCursorPos(1, 10)
- colore(colors.black)
- term.write("Nome utente:")
- term.setCursorPos(15, 10)
- colore(colors.white)
- utenteAccettato = false
- conteggioErrori = 0
- while utenteAccettato == false do
- utente = read()
- utente = string.gsub(utente, "%s", "")
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
- tabcheckuser = textutils.unserialize(checkuser)
- if tabcheckuser.stato == "OK" then
- term.setCursorPos(15, 10)
- colore(colors.lime)
- term.write(utente)
- colore(colors.white)
- utenteAccettato = true
- else
- term.setCursorPos(15, 10)
- colore(colors.red)
- term.write("Utente errato! ")
- sleep(2)
- term.setCursorPos(15, 10)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 10)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(15, 10)
- colore(colors.red)
- term.write("Tre tentativi di immissione errati.")
- sleep(2)
- term.setCursorPos(15, 10)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 10)
- clear()
- os.reboot()
- end
- end
- end
- --password
- colore(colors.black)
- term.setCursorPos(1,12)
- term.write("Password:")
- term.setCursorPos(15, 12)
- conteggioErrori = 0
- passAccettata = false
- while passAccettata == false do
- colore(colors.white)
- password = read("#")
- password = string.gsub(password, "%s", "")
- colore(colors.black)
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
- risposta = textutils.unserialize(checkuser)
- if risposta.stato == "OK" then
- term.setCursorPos(15, 12)
- colore(colors.lime)
- term.write("############## ")
- colore(colors.white)
- passAccettata = true
- else
- term.setCursorPos(15, 12)
- colore(colors.red)
- term.write("Password errata! ")
- conteggioErrori = conteggioErrori + 1
- sleep(2)
- term.setCursorPos(15, 12)
- term.write(" ")
- term.setCursorPos(15, 12)
- if conteggioErrori > 2 then
- term.setCursorPos(15, 12)
- colore(colors.red)
- term.write("Tre tentativi di immissione errati.")
- sleep(2)
- term.setCursorPos(15, 12)
- term.write(" ")
- term.setCursorPos(15, 12)
- clear()
- os.reboot()
- end
- end
- end
- conteggioErrori = 0
- -- Pagina in cui scegli le operazioni da fare
- while true do
- --Ricontrolla il saldo per gestire l'aggiornamento di piåB9 operazioni
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
- risposta = textutils.unserialize(checkuser)
- saldo = tonumber(risposta.saldo)
- --Disegna la finestra del pannello utente
- clear()
- titolo("Pannello utente nPay")
- term.setCursorPos(1, 3)
- term.write("Benvenuto, ")
- colore(colors.white)
- term.write(utente)
- colore(colors.black)
- term.write("! Saldo: ")
- colore(colors.white)
- term.write(saldo)
- colore(colors.black)
- term.write(" IC")
- print("\n\nOperazioni disponibili:\n")
- sfondo(colors.white)
- print(" Carica denaro su nPay \n")
- print(" Preleva denaro da nPay \n")
- print(" Trasferisci denaro \n")
- print(" Estratto conto \n")
- colore(colors.red)
- print(" Disconnettiti da nPay \n")
- colore(colors.black)
- antitonto = os.startTimer(60)
- event, key, x, y = os.pullEventRaw()
- if event == "mouse_click" and y == 7 and x <= 24 then --Pulsante carica denaro su nPay
- clear()
- titolo("Caricamento denaro su nPay")
- drawCard()
- sfondo(colors.lightBlue)
- colore(colors.black)
- term.setCursorPos(30, 8)
- print("INSERIRE LA CARTA")
- term.setCursorPos(29, 10)
- print("NEL LETTORE IN BASSO")
- drawFilledBox(34, 14, 42, 14, colors.white)
- term.setCursorPos(35, 14)
- term.write("Annulla")
- mag.setInsertCardLight(true)
- finalBreakC = false
- while true do
- event, arg1, arg2, arg3 = os.pullEventRaw()
- if event == "mouse_click" and arg3 == 14 and arg2 >= 34 and arg2 <= 42 then -- arg2 = x | arg3 = y
- mag.setInsertCardLight(false)
- clear()
- term.setCursorPos(1,1)
- break
- elseif event == "mag_swipe" then
- mag.setInsertCardLight(false)
- tabel = textutils.unserialize(arg1)
- if tabel == "" or tabel == nil then
- clear()
- titolo("Caricamento denaro da nPay")
- drawCard()
- sfondo(colors.lightBlue)
- term.setCursorPos(36, 10)
- colore(colors.red)
- term.write("ERRORE!")
- term.setCursorPos(30, 12)
- colore(colors.black)
- term.write("Carta smagnetizzata!")
- os.sleep(3)
- break
- elseif tabel.t ~= "cc" or tabel.e ~= "BN" then
- clear()
- titolo("Caricamento denaro da nPay")
- drawCard()
- sfondo(colors.lightBlue)
- term.setCursorPos(36, 10)
- colore(colors.red)
- term.write("ERRORE!")
- term.setCursorPos(31, 12)
- colore(colors.black)
- term.write("Carta non valida!")
- os.sleep(3)
- break
- else
- while true do
- clear()
- titolo("Caricamento denaro su nPay")
- colore(colors.gray)
- print("\n\nDisponibilitåA0 su carta: " .. tabel.v .. " IC")
- colore(colors.red)
- term.setCursorPos(1, 14)
- term.write("ATTENZIONE:")
- colore(colors.black)
- term.setCursorPos(1, 15)
- term.write("Eccezionalmente, grazie ai 600 voti di marzo,")
- --term.write("Per le operazioni inferiori a 50 000 IC,")
- term.setCursorPos(1, 16)
- print("le operazioni saranno GRATUITE fino al 4 aprile!")
- --print("si applica una commissione del 0.15%.")
- --print("Oltre 50 000 IC la commissione åA8 del 0.05%.")
- term.setCursorPos(1, 5)
- term.write("Importo da caricare: ")
- colore(colors.white)
- credito = tonumber(tabel.v)
- credit = read()
- if tonumber(credit) == "" or tonumber(credit) == nil or tonumber(credit) <= 0 then
- colore(colors.red)
- term.setCursorPos(22, 5)
- term.write("Importo errato! ")
- colore(colors.black)
- sleep(1.5)
- clear()
- else
- if tonumber(credit) >= 50000 then
- --commissioni = tonumber(credit) * 0.005
- commissioni = tonumber(credit) * 0
- else
- --commissioni = tonumber(credit) * 0.015
- commissioni = tonumber(credit) * 0
- end
- crediton = credit + commissioni
- if tonumber(tabel.v) >= crediton then
- tab = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=" .. utente .. "&auth=" .. password .. "&richiesta=accredito&valore=" .. credit).readAll()
- tabella = textutils.unserialize(tab)
- tabr = {}
- tabr.t = tabel.t
- tabr.e = tabel.e
- tabr.p = tabel.p
- tabr.v = tonumber(tabel.v) - crediton
- ncr = textutils.serialize(tabr)
- clear()
- titolo("Caricamento denaro su nPay")
- drawCard()
- colore(colors.black)
- sfondo(colors.lightBlue)
- term.setCursorPos(29, 10)
- print("RE-INSERIRE LA CARTA")
- term.setCursorPos(29, 12)
- print("NEL LETTORE IN BASSO")
- mag.setInsertCardLight(true)
- mag.beginWrite(ncr, bl)
- za2, carta = os.pullEvent("mag_write_done")
- mag.setInsertCardLight(false)
- clear()
- titolo("Caricamento denaro su nPay")
- colore(colors.lime)
- term.setCursorPos(1, 3)
- print("Operazione completata!")
- colore(colors.black)
- term.setCursorPos(1, 5)
- print("Denaro accreditato: " .. credit .. " IC")
- print("Commissioni: " .. commissioni .. " IC")
- term.setCursorPos(1, 8)
- print("Saldo sul conto: " .. tabella.credito .. " IC")
- print("Saldo sulla carta: " .. tabr.v .. " IC")
- sfondo(colors.white)
- term.setCursorPos(1, 12)
- term.write(" Torna alla pagina principale ")
- sfondo(colors.lightBlue)
- antiTonto2 = os.startTimer(15)
- while true do
- local event, arg1, arg2, arg3 = os.pullEventRaw()
- if event == "mouse_click" and arg3 == 12 and arg2 <= 30 or event == "timer" and arg1 == antiTonto2 then -- arg2 = x | arg3 = y
- finalBreakC = true
- break
- end
- end
- break
- else
- colore(colors.red)
- term.setCursorPos(22, 5)
- term.write("Credito su carta insufficente.")
- colore(colors.black)
- sleep(1.5)
- clear()
- end
- end
- end
- if finalBreakC then
- break
- end
- end
- end
- end
- elseif event == "mouse_click" and y == 9 and x <= 24 then --Pulsante preleva denaro da nPay
- clear()
- titolo("Prelievo denaro da nPay")
- drawCard()
- sfondo(colors.lightBlue)
- colore(colors.black)
- term.setCursorPos(30, 8)
- print("INSERIRE LA CARTA")
- term.setCursorPos(29, 10)
- print("NEL LETTORE IN BASSO")
- drawFilledBox(34, 14, 42, 14, colors.white)
- term.setCursorPos(35, 14)
- term.write("Annulla")
- mag.setInsertCardLight(true)
- finalBreakP = false
- while true do
- event, arg1, arg2, arg3 = os.pullEventRaw()
- if event == "mouse_click" and arg3 == 14 and arg2 >= 34 and arg2 <= 42 then -- arg2 = x | arg3 = y
- mag.setInsertCardLight(false)
- clear()
- term.setCursorPos(1,1)
- break
- elseif event == "mag_swipe" then
- mag.setInsertCardLight(false)
- sfondo(colors.lightBlue)
- clear()
- tabel = textutils.unserialize(arg1)
- if tabel == "" or tabel == nil then
- clear()
- titolo("Prelievo denaro da nPay")
- drawCard()
- sfondo(colors.lightBlue)
- term.setCursorPos(36, 10)
- colore(colors.red)
- term.write("ERRORE!")
- term.setCursorPos(30, 12)
- colore(colors.black)
- term.write("Carta smagnetizzata!")
- os.sleep(3)
- break
- elseif tabel.t ~= "cc" or tabel.e ~= "BN" then
- clear()
- titolo("Prelievo denaro da nPay")
- drawCard()
- sfondo(colors.lightBlue)
- term.setCursorPos(36, 10)
- colore(colors.red)
- term.write("ERRORE!")
- term.setCursorPos(31, 12)
- colore(colors.black)
- term.write("Carta non valida!")
- os.sleep(3)
- break
- else
- while true do
- tabr = {}
- tabr.e = tabel.e
- tabr.p = tabel.p
- tabr.t = tabel.t
- tab1 = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=" .. utente .. "&auth=" .. password .. "&richiesta=accredito&valore=0").readAll()
- tab3 = textutils.unserialize(tab1)
- clear()
- titolo("Prelievo denaro da nPay")
- colore(colors.gray)
- print("\n\nDisponibilitåA0 su conto: " .. saldo .. " IC")
- colore(colors.black)
- term.setCursorPos(1, 5)
- term.write("Importo da ritirare: ")
- colore(colors.white)
- credito = tonumber(tabel.v)
- credit = read()
- if tonumber(credit) == "" or tonumber(credit) == nil or tonumber(credit) <= 0 then
- colore(colors.red)
- term.setCursorPos(22, 5)
- term.write("Importo errato! ")
- colore(colors.black)
- sleep(1.5)
- clear()
- else
- tab = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=" .. utente .. "&auth=" .. password .. "&richiesta=addebito&valore=" .. credit).readAll()
- tabella = textutils.unserialize(tab)
- if tabella.stato == "DI" then
- colore(colors.red)
- term.setCursorPos(22, 5)
- term.write("Credito su carta insufficente.")
- colore(colors.black)
- sleep(1.5)
- clear()
- else
- tabr.v = tonumber(tabel.v) + tonumber(credit)
- ncr = textutils.serialize(tabr)
- mag.setInsertCardLight(true)
- mag.beginWrite(ncr, bl)
- clear()
- titolo("Prelievo denaro da nPay")
- drawCard()
- colore(colors.black)
- sfondo(colors.lightBlue)
- term.setCursorPos(29, 10)
- print("RE-INSERIRE LA CARTA")
- term.setCursorPos(29, 12)
- print("NEL LETTORE IN BASSO")
- mag.setInsertCardLight(true)
- event = os.pullEvent("mag_write_done")
- mag.setInsertCardLight(false)
- clear()
- titolo("Prelievo denaro da nPay")
- colore(colors.lime)
- term.setCursorPos(1, 3)
- print("Operazione completata!")
- colore(colors.black)
- term.setCursorPos(1, 5)
- print("Denaro prelevato: " .. credit .. " IC")
- term.setCursorPos(1, 7)
- print("Saldo sul conto: " .. tabella.credito .. " IC")
- print("Saldo sulla carta: " .. tabr.v .. " IC")
- sfondo(colors.white)
- term.setCursorPos(1, 11)
- term.write(" Torna alla pagina principale ")
- sfondo(colors.lightBlue)
- antiTonto2 = os.startTimer(15)
- while true do
- local event, arg1, arg2, arg3 = os.pullEventRaw()
- if event == "mouse_click" and arg3 == 11 and arg2 <= 30 or event == "timer" and arg1 == antiTonto2 then -- arg2 = x | arg3 = y
- finalBreakP = true
- break
- end
- end
- break
- end
- end
- end
- if finalBreakP then
- break
- end
- end
- end
- end
- elseif event == "mouse_click" and y == 11 and x <= 24 then --Pulsante trasferisci denaro
- --Trasferisci denaro
- --inizio pagina
- clear()
- titolo("Trasferimento di denaro")
- term.setCursorPos(1, 3)
- term.write("Inserire il nome utente del beneficiario.")
- colore(colors.gray)
- print("\n\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA0 verde.\nSe sono errati, il programma chiederåA0 di reinserirli nuovamente.")
- --Mostra saldo
- term.setCursorPos(1, 10)
- colore(colors.gray)
- print("Saldo disponibile: " .. saldo .. " IC")
- colore(colors.black)
- --Verifica Beneficiario
- term.setCursorPos(1, 12)
- term.write("Beneficiario:")
- term.setCursorPos(15, 12)
- colore(colors.white)
- destAccettato = false
- conteggioErrori = 0
- while destAccettato == false do
- beneficiario = read()
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. beneficiario).readAll()
- tabcheckuser = textutils.unserialize(checkuser)
- if tabcheckuser.stato == "OK" and beneficiario ~= utente then
- term.setCursorPos(15, 12)
- colore(colors.lime)
- term.write(beneficiario)
- colore(colors.white)
- destAccettato = true
- else
- conteggioErrori = conteggioErrori + 1
- term.setCursorPos(15, 12)
- colore(colors.red)
- if beneficiario == utente then
- term.write("Non puoi inserire te stesso.")
- else
- term.write("Utente inesistente! ")
- end
- sleep(2)
- term.setCursorPos(15, 12)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 12)
- if conteggioErrori > 2 then
- term.setCursorPos(15, 12)
- colore(colors.red)
- term.write("Tre tentativi di immissione errati.")
- sleep(2)
- term.setCursorPos(15, 12)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 12)
- clear()
- os.reboot()
- end
- end
- end
- colore(colors.black)
- --Verifica valore dell'invio
- term.setCursorPos(1, 14)
- term.write("Importo:")
- term.setCursorPos(15, 14)
- colore(colors.white)
- importoAccettato = false
- conteggioErrori = 0
- while importoAccettato == false do
- importo = tonumber(read())
- if importo == "" or importo == nil or importo <= 0 then
- conteggioErrori = conteggioErrori + 1
- term.setCursorPos(15, 14)
- colore(colors.red)
- term.write("Importo errato! ")
- sleep(2)
- term.setCursorPos(15, 14)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 14)
- elseif importo <= saldo and importo > 0 then
- term.setCursorPos(15, 14)
- colore(colors.lime)
- term.write(importo .. " IC")
- colore(colors.white)
- importoAccettato = true
- else
- conteggioErrori = conteggioErrori + 1
- term.setCursorPos(15, 14)
- colore(colors.red)
- term.write("Credito insufficiente! ")
- sleep(2)
- term.setCursorPos(15, 14)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 14)
- if conteggioErrori > 2 then
- term.setCursorPos(15, 14)
- colore(colors.red)
- term.write("Tre tentativi di immissione errati.")
- sleep(2)
- term.setCursorPos(15, 14)
- colore(colors.white)
- term.write(" ")
- term.setCursorPos(15, 14)
- clear()
- os.reboot()
- end
- end
- end
- sleep(0.5)
- clear()
- titolo("Riepilogo del trasferimento")
- text = "Vuoi inviare " .. importo .. " IC a " .. beneficiario .. "?"
- term.setCursorPos((maxw - #text) / 2, 6)
- term.write("Vuoi inviare ")
- colore(colors.white)
- term.write(tostring(importo) .. " IC ")
- colore(colors.black)
- term.write("a ")
- colore(colors.white)
- term.write(beneficiario)
- colore(colors.black)
- term.write("?")
- drawFilledBox(7, 11, 23, 13, colors.white)
- drawFilledBox(29, 11, 45, 13, colors.white)
- term.setCursorPos(8, 12)
- colore(colors.lime)
- term.write("Invia il denaro")
- term.setCursorPos(34, 12)
- colore(colors.red)
- term.write("Annulla")
- inviare = false
- while true do
- event, key, x, y = os.pullEvent()
- if event == "mouse_click" and x >= 7 and x <= 23 and y >= 11 and y <= 13 then
- inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. importo .. "&beneficiario=" .. beneficiario).readAll()
- risultatoInvio = textutils.unserialize(inviaDenaro)
- if risultatoInvio.stato == "OK" then
- text = "Invio del denaro riuscito."
- text2 = "Nuovo saldo: " .. risultatoInvio.credito .. " IC"
- sfondo(colors.lightBlue)
- colore(colors.lime)
- term.setCursorPos((maxw - #text) / 2, 16)
- term.write(text)
- colore(colors.black)
- term.setCursorPos((maxw - #text2) / 2, 18)
- term.write(text2)
- sleep(2)
- clear()
- break
- else
- text = "Errore durante l'invio del denaro."
- text2 = risultatoInvio.errore
- sfondo(colors.lightBlue)
- colore(colors.red)
- term.setCursorPos((maxw - #text) / 2, 16)
- term.write(text)
- colore(colors.black)
- term.setCursorPos((maxw - #text2) / 2, 18)
- term.write(text2)
- sleep(2)
- clear()
- break
- end
- elseif event == "mouse_click" and x >= 29 and x <= 45 and y >= 11 and y <= 13 then
- sfondo(colors.lightBlue)
- colore(colors.red)
- text = "Operazione annullata."
- term.setCursorPos((maxw - #text) / 2, 16)
- term.write(text)
- sleep(1.5)
- clear()
- break
- end
- end
- elseif event == "mouse_click" and y == 13 and x <= 24 then --Pulsante estratto conto
- --Estratto Conto (inizio pagina)
- clear()
- titolo("Estratto conto")
- estratto = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=estratto").readAll()
- ec = textutils.unserialize(estratto)
- term.setCursorPos(1, 3)
- print("Entrate:")
- colore(colors.lime)
- print(ec.entrata1)
- print(ec.entrata2)
- print(ec.entrata3)
- print(ec.entrata4)
- colore(colors.black)
- print("\nUscite:")
- colore(colors.red)
- print(ec.uscita1)
- print(ec.uscita2)
- print(ec.uscita3)
- print(ec.uscita4)
- term.setCursorPos(1, 18)
- sfondo(colors.white)
- colore(colors.black)
- term.write(" Torna al menåB9 principale ")
- while true do
- event, key, x, y = os.pullEventRaw()
- if event == "mouse_click" and x <= 26 and y == 18 then
- break
- end
- end
- elseif event == "mouse_click" and y == 15 and x <= 24 then --Pulsante disconnetti da nPay
- disconnetti()
- elseif event == "timer" and key == antitonto then --Butta fuori l'utente se non fa niente
- disconnetti()
- elseif event == "mouse_click" and x == maxw and y == maxh then -- Auto aggiornamento su magic corner (pannello utente)
- update()
- end
- end
- elseif event == "mouse_click" and x == maxw and y == maxh then -- Auto aggiornamento su magic corner (schermata principale)
- update()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement