Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Pompa petrolio al rovescio
- -- Configurazione
- local price = 0.3
- local meter = peripheral.wrap("bottom")
- local meterDisplay = "left"
- local maxw, maxh = term.getSize()
- -- Reset variabili
- local oil = 0
- local contanti = 0
- -- Accensione display di destra
- rs.setOutput("right", true)
- -- Blocca contatore
- rs.setOutput("bottom", true)
- function clear()
- 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
- -- 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 titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.yellow)
- term.setCursorPos((maxw - #testo) / 2, 1)
- colore(colors.black)
- term.write(testo)
- term.setBackgroundColor(colors.black)
- colore(colors.white)
- 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
- oil = meter.getAmount()
- if oil > 0 then
- -- Sblocca il contatore, così si svuota, attendi e riblocca
- rs.setOutput("bottom", true)
- meter.reset()
- errore("Pompa temporaneamente non disponibile.\n\nLavaggio circuiti in corso...")
- sleep(10)
- rs.setOutput("bottom", false)
- os.reboot()
- end
- clear()
- titolo("NuovoPignone DigitalPump")
- print("\n\nPECTEN S.p.A.")
- print("")
- print("Premere un tasto per iniziare l'operazione")
- print("")
- colore(colors.orange)
- print("ATTENZIONE, AVVERTENZA MOLTO IMPORTANTE")
- print("NON RIAVVIARE MAI IL COMPUTER DURANTE IL POMPAGGIO")
- print("In caso contrario, il petrolio pompato verrà perduto!")
- os.pullEvent("key")
- sfondo(colours.blue)
- term.clear()
- term.setCursorPos(1, 1)
- titolo("Accredita su 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()
- 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, 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
- metodoPagamento = "NPAY"
- credito = tonumber(risposta.saldo)
- sfondo(colors.black)
- clear()
- titolo("NuovoPignone DigitalPump")
- while true do
- print("\n\n")
- print("Il conto ha un saldo di "..credito.." IC.")
- print("")
- print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
- print("")
- colore(colors.lime)
- print("[1] Scaricare il petrolio")
- colore(colors.red)
- print("[2] Annullare il pompaggio")
- colore(colors.white)
- num=tonumber(read())
- if num == 1 then
- clear()
- titolo("NuovoPignone DigitalPump")
- sfondo(colors.black)
- print("\n\n")
- print("Posizionare i vagoni sul dispositivo di pompaggio")
- print("")
- print("AVVERTENZA IMPORTANTE:")
- print("Accetta SOLO petrolio.")
- print("")
- print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
- print("")
- print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
- os.pullEvent("key")
- --Ricalibra e sblocca il contatore. Accendi display di sinistra
- meter.reset()
- rs.setOutput(meterDisplay, true)
- rs.setOutput("bottom", false)
- clear()
- while true do
- clear()
- titolo("NuovoPignone DigitalPump")
- sfondo(colors.black)
- print("\n\n")
- print("Pompaggio in corso.\n\nPremere il tasto S per terminare.")
- local event, key = os.pullEvent("key")
- if event == "key" and key == 31 then
- break
- end
- sleep(0.1)
- end
- -- Conta il piscio e ricalibra
- clear()
- titolo("NuovoPignone DigitalPump")
- sfondo(colors.black)
- print("\n\n")
- print("Calibrazione in corso, attendere")
- while true do
- oil = meter.getAmount()
- term.setCursorPos(3, 3)
- term.write("*--")
- sleep(1)
- term.setCursorPos(3, 3)
- term.write("-*-")
- sleep(1)
- if oil == meter.getAmount() then
- break
- end
- term.setCursorPos(3, 3)
- term.write("--*")
- end
- --Blocca contatore
- rs.setOutput("bottom", true)
- clear()
- -- millibucket -> bucket
- oil = oil / 1000
- contanti = oil * price
- titolo ("Vendita completata!")
- print("\n\n")
- print("Totale pompato: "..oil.." secchi")
- print("Prezzo unitario: "..price.." IC/secchio")
- print("Pagato: "..contanti.." IC")
- print("")
- sleep(1)
- inviaDenaro = http.get(
- "http://172.16.20.220/luanet/servlets/pecten/npayproxy.php?beneficiario=" .. utente ..
- "&valore=" .. contanti).readAll()
- risultatoInvio = textutils.unserialize(inviaDenaro)
- if risultatoInvio.stato == "OK" then
- colore(colors.white)
- alert = http.get("http://172.16.20.220/luanet/servlets/pecten/email_service.php?auth=BEAFFBAC111&npay=" .. utente .. "&qty=" .. contanti .. "&success=true").readAll()
- else
- clear()
- alert = http.get("http://172.16.20.220/luanet/servlets/pecten/email_service.php?auth=BEAFFBAC111&npay=" .. utente .. "&qty=" .. contanti .. "&success=false").readAll()
- errore("Errore durante il pagamento.\n\nPer favore contattare un responsabile Pecten.\n\nQuesto evento è stato segnalato al Supporto Tecnico Pecten.")
- sleep(10)
- os.reboot()
- end
- sleep(1)
- print("Denaro versato.")
- print("")
- print("")
- print("Grazie!")
- sleep(1)
- --Spegni display di sinistra e ricalibra
- meter.reset()
- rs.setOutput(meterDisplay, false)
- term.setTextColor(colors.black)
- clear()
- shell.run("pastebin get fc3G1D61 startup2")
- if fs.exists("startup2") then
- shell.run("rm startup")
- shell.run("mv startup2 startup")
- end
- os.reboot()
- elseif num == 2 then clear() break end
- end
- clear()
- print("Attendere")
- term.setTextColor(colors.black)
- shell.run("pastebin get fc3G1D61 startup2")
- if fs.exists("startup2") then
- shell.run("rm startup")
- shell.run("mv startup2 startup")
- end
- os.reboot()
Add Comment
Please, Sign In to add comment