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 colore(nome) term.setTextColor(nome) end
- function sfondo(nome) term.setBackgroundColor(nome) end
- function fineColore() term.setTextColour(colours.white) end
- function fineSfondo() term.setBackgroundColour(colours.black) 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.blue)
- end
- function clear()
- sfondo(colors.blue)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function errore(errore)
- sfondo(colors.red)
- colore(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- titolo("Errore irreversibile")
- term.setCursorPos(1, 3)
- sfondo(colors.red)
- colore(colors.white)
- print(errore)
- print("\n\n\nAttendere qualche secondo...")
- os.sleep(5)
- os.reboot()
- end
- mappa = paintutils.loadImage("sfondo")
- sfondo(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- colore(colors.white)
- paintutils.drawImage(mappa, 1, 2)
- colore(colors.black)
- sfondo(colors.white)
- term.setCursorPos(14, 1)
- term.write("Registrazione concessione petrolifera")
- colore(colors.white)
- sfondo(colors.lime)
- term.setCursorPos(31, 10)
- term.write("Registra una")
- term.setCursorPos(31, 11)
- term.write("concessione")
- term.setCursorPos(31, 12)
- term.write("petrolifera")
- while true do
- local event, par1, par2, par3 = os.pullEvent("mouse_click")
- if par2 >= 31 and par2 <= 42 and par3 >= 10 and par3 <= 12 then
- sfondo(colours.blue)
- term.clear()
- term.setCursorPos(1, 1)
- titolo("Ministero delle Georisorse")
- sfondo(colours.blue)
- colore(colors.white)
- print(
- "\n\nInserire i propri dati. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.")
- -- nomeutente
- term.setCursorPos(1, 9)
- term.write("Nome utente nPay:")
- term.setCursorPos(21, 9)
- fineColore()
- utenteAccettato = false
- conteggioErrori = 0
- while utenteAccettato == false do
- utente = read()
- 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(21, 9)
- colore(colours.lime)
- term.write(utente)
- fineColore()
- utenteAccettato = true
- else
- term.setCursorPos(21, 9)
- colore(colours.red)
- term.write("Utente errato! ")
- sleep(2)
- term.setCursorPos(21, 9)
- fineColore()
- term.write(" ")
- term.setCursorPos(21, 9)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(21, 9)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati ")
- end
- end
- end
- colore(colours.white)
- term.setCursorPos(1, 11)
- term.write("Password nPay:")
- term.setCursorPos(21, 11)
- conteggioErrori = 0
- passAccettata = false
- while passAccettata == false do
- fineColore()
- password = read("#")
- colore(colours.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(21, 11)
- colore(colours.lime)
- term.write("############## ")
- fineColore()
- passAccettata = true
- else
- term.setCursorPos(21, 11)
- colore(colours.red)
- term.write("Password errata! ")
- conteggioErrori = conteggioErrori + 1
- sleep(2)
- term.setCursorPos(21, 11)
- term.write(" ")
- term.setCursorPos(21, 11)
- if conteggioErrori > 2 then
- term.setCursorPos(21, 11)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati")
- end
- end
- end
- colore(colours.white)
- term.setCursorPos(1, 13)
- term.write("Coordinata X:")
- term.setCursorPos(21, 13)
- xAccettato = false
- while xAccettato == false do
- x = read()
- if tonumber(x) == "" or tonumber(x) == nil then
- term.setCursorPos(21, 13)
- colore(colours.red)
- term.write("Coord. X errata! ")
- sleep(2)
- term.setCursorPos(21, 13)
- fineColore()
- term.write(" ")
- term.setCursorPos(21, 13)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(21, 13)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati ")
- end
- else
- term.setCursorPos(21, 13)
- colore(colours.lime)
- term.write(x)
- fineColore()
- xAccettato = true
- end
- end
- colore(colours.white)
- term.setCursorPos(1, 15)
- term.write("Coordinata Y:")
- term.setCursorPos(21, 15)
- yAccettato = false
- while yAccettato == false do
- y = read()
- if tonumber(y) == "" or tonumber(y) == nil then
- term.setCursorPos(21, 15)
- colore(colours.red)
- term.write("Coord. Y errata! ")
- sleep(2)
- term.setCursorPos(21, 15)
- fineColore()
- term.write(" ")
- term.setCursorPos(21, 15)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(21, 15)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati ")
- end
- else
- term.setCursorPos(21, 15)
- colore(colours.lime)
- term.write(y)
- fineColore()
- yAccettato = true
- end
- end
- colore(colours.white)
- term.setCursorPos(1, 17)
- term.write("Coordinata Z:")
- term.setCursorPos(21, 17)
- zAccettato = false
- while zAccettato == false do
- z = read()
- if tonumber(z) == "" or tonumber(z) == nil then
- term.setCursorPos(21, 17)
- colore(colours.red)
- term.write("Coord. Z errata! ")
- sleep(2)
- term.setCursorPos(21, 17)
- fineColore()
- term.write(" ")
- term.setCursorPos(21, 17)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(21, 17)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati ")
- end
- else
- term.setCursorPos(21, 17)
- colore(colours.lime)
- term.write(z)
- fineColore()
- zAccettato = true
- end
- end
- -- Mostra saldo
- term.clear()
- term.clear()
- term.setCursorPos(1, 1)
- titolo("Paga con Nebraska Pay")
- sfondo(colours.blue)
- colore(colors.white)
- print("\n\nSaldo disponibile: " .. risposta.saldo .. " IC")
- importo = 200
- if tonumber(risposta.saldo) >= tonumber(importo) then
- importoAccettato = true
- else
- errore("Disponibilità insufficiente!")
- end
- term.setCursorPos(1, 3)
- term.write("Invio di ")
- term.write(importo)
- term.write(" IC a favore di ")
- term.write("Min. Georisorse")
- print("\n\nConfermare l'operazione?")
- colore(colors.yellow)
- print("\n\nInvia il denaro Annulla")
- while true do
- event, key, x, y = os.pullEvent()
- if event == "mouse_click" and x < 16 and y == 8 then
- inviaDenaro = http.get(
- "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" ..
- password .. "&utente=" .. utente ..
- "&richiesta=trasferimento&valore=" ..
- importo .. "&beneficiario=ComuneNR")
- .readAll()
- risultatoInvio = textutils.unserialize(inviaDenaro)
- if risultatoInvio.stato == "OK" then
- colore(colors.white)
- break
- else
- clear()
- errore("Errore durante il pagamento")
- end
- elseif event == "mouse_click" and x > 18 and y == 8 then
- errore("Pagamento annullato dall'utente.")
- end
- end
- conferma = textutils.unserialize(
- http.get(
- "http://172.16.20.220/luanet/servlets/conc_petrolifera/?nome=" ..
- utente .. "&x=" .. x .. "&y=" .. y .. "&z=" .. z)
- .readAll())
- if conferma.stato == "OK" then
- clear()
- titolo("Ministero delle Georisorse")
- term.setCursorPos(1, 3)
- colore(colors.white)
- print("Grazie per l'acquisto!\n\n")
- print("Questo è il codice della concessione: " ..
- conferma.dettaglio)
- print(
- "\nIL CODICE VA SCRITTO SU UN CARTELLO VICINO ALLA CONCESSIONE!")
- print(
- "\nIn caso di ispezione se non è presente il numero, si incorrerà in una sanzione amministrativa sino a 4000 IC.")
- os.sleep(10)
- os.reboot()
- else
- errore(conferma.errore)
- end
- end
- sleep(0.1)
- end
Add Comment
Please, Sign In to add comment