Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local maxw, maxh = term.getSize()
- function creditoInsufficiente()
- clearRed()
- print("Credito insufficiente.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- function prodottoEsaurito()
- clearRed()
- print("Prodotto esaurito.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- -- 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.black)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function clearRed()
- sfondo(colors.red)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function colore(sfumatura) term.setTextColour(sfumatura) end
- function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) 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 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
- sfondo(colours.blue)
- term.clear()
- term.setCursorPos(1, 1)
- titolo("Pagamento rapido con Nebraska Pay")
- 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:")
- term.setCursorPos(15, 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(15, 9)
- colore(colours.lime)
- term.write(utente)
- fineColore()
- utenteAccettato = true
- else
- term.setCursorPos(15, 9)
- colore(colours.red)
- term.write("Utente errato! ")
- sleep(2)
- term.setCursorPos(15, 9)
- fineColore()
- term.write(" ")
- term.setCursorPos(15, 9)
- conteggioErrori = conteggioErrori + 1
- if conteggioErrori > 2 then
- term.setCursorPos(15, 9)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati ")
- end
- end
- end
- colore(colours.white)
- term.setCursorPos(1, 11)
- term.write("Password:")
- term.setCursorPos(15, 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(15, 11)
- colore(colours.lime)
- term.write("############## ")
- fineColore()
- passAccettata = true
- else
- term.setCursorPos(15, 11)
- colore(colours.red)
- term.write("Password errata! ")
- conteggioErrori = conteggioErrori + 1
- sleep(2)
- term.setCursorPos(15, 11)
- term.write(" ")
- term.setCursorPos(15, 11)
- if conteggioErrori > 2 then
- term.setCursorPos(15, 11)
- colore(colours.red)
- errore("Troppi tentativi di immissione errati")
- end
- end
- end
- while true do
- clear()
- titolo("HIGHLAND LUMBER ")
- colore(colors.white)
- sfondo(colors.red)
- term.setCursorPos(35, 1)
- term.write(" CHIUDI SESSIONE ")
- fineColore()
- fineSfondo()
- print("")
- print("\nProdotto Prezzo")
- p = {}
- -- nome, prezzo, id, meta, colore cavo
- p[1] = {"Oak", 54, 17, 0, 1}
- p[2] = {"Spruce", 54, 17, 1, 2}
- p[3] = {"Birch", 54, 17, 2, 4}
- p[4] = {"Larch", 162, 1388, 0, 8}
- p[5] = {"Teak", 162, 1388, 1, 16}
- p[6] = {"Acacia", 162, 1388, 2, 32}
- p[7] = {"Walnut", 162, 1391, 1, 64}
- p[8] = {"Chestnut", 162, 1389, 0, 128}
- p[9] = {"Wenge", 162, 1389, 1, 256}
- p[10] = {"Baobab", 162, 1389, 2, 512}
- p[11] = {"Sequoia", 162, 1389, 3, 1024}
- p[12] = {"Kapok", 162, 1390, 0, 2048}
- p[13] = {"Ebony", 162, 1390, 1, 4096}
- p[14] = {"Mahogany", 162, 1390, 2, 8192}
- p[15] = {"Balsa", 162, 1390, 3, 16384}
- p[16] = {"Willow", 162, 1391, 0, 32768}
- ypos = 4
- for k, v in pairs(p) do
- term.setCursorPos(1, ypos)
- term.write(v[1])
- term.setCursorPos(20, ypos)
- term.write(v[2])
- term.setCursorPos(30, ypos)
- if alt == false then
- sfondo(colors.lightBlue)
- alt = true
- else
- sfondo(colors.blue)
- alt = false
- end
- colore(colors.white)
- term.write(" Compra ")
- fineSfondo()
- fineColore()
- ypos = ypos + 1
- end
- while true do
- local event, par1, x, y = os.pullEvent("mouse_click")
- if event == "mouse_click" and y > 3 then
- prodotto = p[y - 3]
- break
- elseif event == "mouse_click" and y == 1 then
- os.reboot()
- end
- sleep(1)
- end
- clear()
- print(prodotto[1])
- if colors.test(redstone.getBundledInput("bottom"), prodotto[5]) == true then
- prodottoEsaurito()
- end
- term.clear()
- term.setCursorPos(1, 1)
- titolo("Paga con Nebraska Pay")
- sfondo(colours.blue)
- colore(colors.white)
- print("\n\nSaldo disponibile: " .. risposta.saldo .. " IC")
- if tonumber(risposta.saldo) >= tonumber(prodotto[2]) then
- prezzoAccettato = true
- else
- errore("Disponibilità insufficiente!")
- end
- term.setCursorPos(1, 3)
- term.write("Invio di ")
- term.write(prodotto[2])
- term.write(" IC a favore di ")
- term.write("Highland Mining")
- 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=" ..
- prodotto[2] .. "&beneficiario=HighlandMining&causale=Merce%20ingrosso%20Crianlarich")
- .readAll()
- risultatoInvio = textutils.unserialize(inviaDenaro)
- if risultatoInvio.stato == "OK" then
- 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
- clear()
- titolo("Erogazione in corso")
- fineSfondo()
- fineColore()
- print("\n\nErogazione di un vagone di " .. prodotto[1] .. " in corso...")
- print("\nATTENZIONE: IMPIANTO LOGISTIC LENTO, ATTENDERE")
- sfondo(colors.red)
- colore(colors.white)
- ben = peripheral.wrap("back")
- ben.makeRequest(ben.getItemIdentifierIDFor(prodotto[3], prodotto[4]), 3456)
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement