Advertisement
lego11

Versamento frigor

Feb 15th, 2022 (edited)
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Versamenti GELATI
  2. local maxw, maxh = term.getSize()
  3.  
  4. -- vuota il bancomat
  5. ben = peripheral.wrap("back")
  6. ben.getAvailableItems()
  7. i, j = os.pullEvent("available_items_return")
  8.  
  9. conoStracciatella = 0
  10. conoFiordilatte = 0
  11. conoCioccolato = 0
  12.  
  13. conoStracciatellaID = ben.getItemIdentifierIDFor(10292, 0)
  14. conoFiordilatteID = ben.getItemIdentifierIDFor(10293, 0)
  15. conoCioccolatoID = ben.getItemIdentifierIDFor(10290, 0)
  16.  
  17. for k, v in pairs(j) do
  18.     if v[1] == conoStracciatellaID then
  19.         conoStracciatella = v[2]
  20.         ben.makeRequest(conoStracciatellaID, v[2])
  21.  
  22.     elseif v[1] == conoFiordilatteID then
  23.         conoFiordilatte = v[2]
  24.         ben.makeRequest(conoFiordilatteID, v[2])
  25.  
  26.     elseif v[1] == conoCioccolatoID then
  27.         conoCioccolato = v[2]
  28.         ben.makeRequest(conoCioccolatoID, v[2])
  29.         sleep(0.1)
  30.     end
  31. end
  32.  
  33. ben.getAvailableItems()
  34. i, j = os.pullEvent("available_items_return")
  35.  
  36. conoStracciatellaID = ben.getItemIdentifierIDFor(10292, 0)
  37. conoFiordilatteID = ben.getItemIdentifierIDFor(10293, 0)
  38. conoCioccolatoID = ben.getItemIdentifierIDFor(10290, 0)
  39.  
  40. for k, v in pairs(j) do
  41.     if v[1] == conoStracciatellaID then
  42.         conoStracciatella = v[2]
  43.         ben.makeRequest(conoStracciatellaID, v[2])
  44.  
  45.     elseif v[1] == conoFiordilatteID then
  46.         conoFiordilatte = v[2]
  47.         ben.makeRequest(conoFiordilatteID, v[2])
  48.  
  49.     elseif v[1] == conoCioccolatoID then
  50.         conoCioccolato = v[2]
  51.         ben.makeRequest(conoCioccolatoID, v[2])
  52.         sleep(0.1)
  53.     end
  54. end
  55.  
  56. function clear()
  57.     term.clear()
  58.     term.setCursorPos(1, 1)
  59. end
  60.  
  61. if conoStracciatella ~= 0 or conoFiordilatte ~= 0 or conoCioccolato ~= 0 then
  62.     clear()
  63.     print("Bancomat temporaneamente non disponibile")
  64.     sleep(60)
  65.     os.reboot()
  66. end
  67.  
  68. function clear()
  69.     term.clear()
  70.     term.setCursorPos(1, 1)
  71. end
  72.  
  73. function clearRed()
  74.     sfondo(colors.red)
  75.     term.clear()
  76.     term.setCursorPos(1, 1)
  77. end
  78.  
  79. function colore(sfumatura) term.setTextColour(sfumatura) end
  80.  
  81. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  82.  
  83. function fineColore() term.setTextColour(colours.white) end
  84.  
  85. function fineSfondo() term.setBackgroundColour(colours.black) end
  86.  
  87. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  88. local function drawPixelInternal(xPos, yPos)
  89.     term.setCursorPos(xPos, yPos)
  90.     term.write(" ")
  91. end
  92.  
  93. local tColourLookup = {}
  94. for n = 1, 16 do
  95.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  96. end
  97.  
  98. function drawFilledBox(startX, startY, endX, endY, nColour)
  99.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  100.         "number" or type(endY) ~= "number" or
  101.         (nColour ~= nil and type(nColour) ~= "number") then
  102.         error("Expected startX, startY, endX, endY, colour", 2)
  103.     end
  104.  
  105.     startX = math.floor(startX)
  106.     startY = math.floor(startY)
  107.     endX = math.floor(endX)
  108.     endY = math.floor(endY)
  109.  
  110.     if nColour then term.setBackgroundColor(nColour) end
  111.     if startX == endX and startY == endY then
  112.         drawPixelInternal(startX, startY)
  113.         return
  114.     end
  115.  
  116.     local minX = math.min(startX, endX)
  117.     if minX == startX then
  118.         minY = startY
  119.         maxX = endX
  120.         maxY = endY
  121.     else
  122.         minY = endY
  123.         maxX = startX
  124.         maxY = startY
  125.     end
  126.  
  127.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  128. end
  129.  
  130. function titolo(testo)
  131.     drawFilledBox(1, 1, maxw, 1, colors.yellow)
  132.     term.setCursorPos((maxw - #testo) / 2, 1)
  133.     colore(colors.black)
  134.     term.write(testo)
  135.     sfondo(colors.blue)
  136. end
  137.  
  138. function errore(errore)
  139.     sfondo(colors.red)
  140.     colore(colors.white)
  141.     term.clear()
  142.     term.setCursorPos(1, 1)
  143.     titolo("Errore irreversibile")
  144.     term.setCursorPos(1, 3)
  145.     sfondo(colors.red)
  146.     colore(colors.white)
  147.     print(errore)
  148.     print("\n\n\nAttendere qualche secondo...")
  149.     os.sleep(5)
  150.     os.reboot()
  151. end
  152.  
  153. clear()
  154. print("FRIGOR - VENDITA GELATI")
  155. print("")
  156. print("Premere un tasto per iniziare l'operazione")
  157. print("")
  158. colore(colors.orange)
  159. print("ATTENZIONE AVVERTENZA MOLTO IMPORTANTE")
  160. print("1. Accetta SOLO coni gelati. NO vaschette!")
  161. print(
  162.     "2. In caso di utilizzo del deep, SI DEVE ATTENDERE CHE LO STESSO SIA COMPLETAMENTE VUOTO PRIMA DI PREMERE TASTI SUL COMPUTER.")
  163. print(
  164.     "   Per versare usando il deep, piazzarlo davanti al cubo rosso ED ATTENDERE CHE SIA VUOTO")
  165. print(
  166.     "   In caso contrario il gelato versato verrà distrutto irrimediabilmente!")
  167. event = os.pullEvent()
  168. sfondo(colours.blue)
  169. term.clear()
  170. term.setCursorPos(1, 1)
  171. titolo("Accredita su Nebraska Pay")
  172. sfondo(colours.blue)
  173. colore(colors.white)
  174. print(
  175.     "\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.")
  176.  
  177. -- nomeutente
  178. term.setCursorPos(1, 9)
  179. term.write("Nome utente:")
  180. term.setCursorPos(15, 9)
  181. fineColore()
  182. utenteAccettato = false
  183. conteggioErrori = 0
  184. while utenteAccettato == false do
  185.     utente = read()
  186.     utente = string.gsub(utente, "%s", "")
  187.     checkuser = http.get(
  188.                     "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" ..
  189.                         utente).readAll()
  190.     tabcheckuser = textutils.unserialize(checkuser)
  191.     if tabcheckuser.stato == "OK" then
  192.         term.setCursorPos(15, 9)
  193.         colore(colours.lime)
  194.         term.write(utente)
  195.         fineColore()
  196.         utenteAccettato = true
  197.     else
  198.         term.setCursorPos(15, 9)
  199.         colore(colours.red)
  200.         term.write("Utente errato!          ")
  201.         sleep(2)
  202.         term.setCursorPos(15, 9)
  203.         fineColore()
  204.         term.write("                       ")
  205.         term.setCursorPos(15, 9)
  206.         conteggioErrori = conteggioErrori + 1
  207.         if conteggioErrori > 2 then
  208.             term.setCursorPos(15, 9)
  209.             colore(colours.red)
  210.             errore("Troppi tentativi di immissione errati    ")
  211.         end
  212.     end
  213. end
  214. colore(colours.white)
  215. term.setCursorPos(1, 11)
  216. term.write("Password:")
  217. term.setCursorPos(15, 11)
  218. conteggioErrori = 0
  219. passAccettata = false
  220. while passAccettata == false do
  221.     fineColore()
  222.     password = read("#")
  223.     colore(colours.black)
  224.     checkuser = http.get(
  225.                     "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" ..
  226.                         password .. "&richiesta=addebito&valore=0&utente=" ..
  227.                         utente).readAll()
  228.     risposta = textutils.unserialize(checkuser)
  229.     if risposta.stato == "OK" then
  230.         term.setCursorPos(15, 11)
  231.         colore(colours.lime)
  232.         term.write("##############               ")
  233.         fineColore()
  234.         passAccettata = true
  235.     else
  236.         term.setCursorPos(15, 11)
  237.         colore(colours.red)
  238.         term.write("Password errata!            ")
  239.         conteggioErrori = conteggioErrori + 1
  240.         sleep(2)
  241.         term.setCursorPos(15, 11)
  242.         term.write("                               ")
  243.         term.setCursorPos(15, 11)
  244.         if conteggioErrori > 2 then
  245.             term.setCursorPos(15, 11)
  246.             colore(colours.red)
  247.             errore("Troppi tentativi di immissione errati")
  248.         end
  249.     end
  250. end
  251. metodoPagamento = "NPAY"
  252. credito = tonumber(risposta.saldo)
  253. clear()
  254.  
  255. while true do
  256.     print("Il conto ha un saldo di " .. credito .. " IC.")
  257.     print("")
  258.     print(
  259.         "Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
  260.     print("")
  261.     print("[1] Versare dei gelati")
  262.     print("[2] Annullare il versamento")
  263.  
  264.     num = tonumber(read())
  265.     if num == 1 then
  266.  
  267.         clear()
  268.         redstone.setOutput("left", true)
  269.         print(
  270.             "Inserire i gelati nello sportello a destra oppure collocare il Deep Storage di fronte al cubo rosso o posizionare")
  271.         print("")
  272.         print("AVVERTENZA IMPORTANTE:")
  273.         print("Inserire SOLO questi gelati:")
  274.         print(
  275.             "Cono stracciatella, cono fiordilatte, gelato cioccolato, gelato stracciatella, gelato fiordilatte")
  276.         print("")
  277.         print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
  278.         print("")
  279.         print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
  280.         os.pullEvent("key")
  281.         clear()
  282.  
  283.         redstone.setOutput("left", false)
  284.  
  285.         print("Conteggio gelati in corso...")
  286.  
  287.         term.setCursorPos(3, 3)
  288.         term.write("*---")
  289.         sleep(0.5)
  290.         term.setCursorPos(3, 3)
  291.         term.write("-*--")
  292.         sleep(0.5)
  293.         term.setCursorPos(3, 3)
  294.         term.write("--*-")
  295.         sleep(0.5)
  296.         term.setCursorPos(3, 3)
  297.         term.write("---*")
  298.         sleep(0.5)
  299.         term.setCursorPos(3, 3)
  300.         term.write("--*-")
  301.         sleep(0.5)
  302.         term.setCursorPos(3, 3)
  303.         term.write("-*--")
  304.         sleep(0.5)
  305.         term.setCursorPos(3, 3)
  306.         term.write("*---")
  307.         sleep(0.5)
  308.  
  309.         ben = peripheral.wrap("back")
  310.         ben.getAvailableItems()
  311.         i, j = os.pullEvent("available_items_return")
  312.  
  313.         clear()
  314.  
  315.         conoStracciatellaID = ben.getItemIdentifierIDFor(10292, 0)
  316.         conoFiordilatteID = ben.getItemIdentifierIDFor(10293, 0)
  317.         conoCioccolatoID = ben.getItemIdentifierIDFor(10290, 0)
  318.  
  319.         for k, v in pairs(j) do
  320.             if v[1] == conoStracciatellaID then
  321.                 conoStracciatella = v[2]
  322.                 ben.makeRequest(conoStracciatellaID, v[2])
  323.  
  324.             elseif v[1] == conoFiordilatteID then
  325.                 conoFiordilatte = v[2]
  326.                 ben.makeRequest(conoFiordilatteID, v[2])
  327.  
  328.             elseif v[1] == conoCioccolatoID then
  329.                 conoCioccolato = v[2]
  330.                 ben.makeRequest(conoCioccolatoID, v[2])
  331.                 sleep(0.1)
  332.             end
  333.         end
  334.  
  335.         conoStracciatellaIC = conoStracciatella * 0.25
  336.         conoFiordilatteIC = conoFiordilatte * 0.23
  337.         conoCioccolatoIC = conoCioccolato * 0.29
  338.  
  339.         contanti = conoStracciatellaIC + conoFiordilatteIC + conoCioccolatoIC
  340.  
  341.         print("Totale versato: " .. contanti .. " IC")
  342.         print("")
  343.         inviaDenaro = http.get(
  344.                           "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" ..
  345.                               password .. "&utente=" .. utente ..
  346.                               "&richiesta=accredito&valore=" .. contanti)
  347.                           .readAll()
  348.         risultatoInvio = textutils.unserialize(inviaDenaro)
  349.         if risultatoInvio.stato == "OK" then
  350.             colore(colors.white)
  351.         else
  352.             clear()
  353.             errore("Errore durante il pagamento")
  354.             sleep(5)
  355.             os.reboot()
  356.         end
  357.         if tonumber(contanti) ~= 0 then
  358.             inviaFisco = http.get(
  359.                              "http://172.16.20.220/luanet/servlets/fisco.php?msg=" ..
  360.                                  contanti .. "%20IC%20di%20gelati%20-%20" ..
  361.                                  utente)
  362.             inviaDGFE = http.get(
  363.                             "http://172.16.20.220/luanet/servlets/dgfe.php?npay_user=" ..
  364.                                 utente ..
  365.                                 "&transaction_type=Gelati%20Frigor&transaction_amount=" ..
  366.                                 contanti)
  367.         end
  368.         sleep(1)
  369.         clear()
  370.         print("Denaro versato.")
  371.         print("")
  372.         print("")
  373.         print("Grazie!")
  374.         sleep(1)
  375.         term.setTextColor(colors.black)
  376.         shell.run("pastebin get 87bE40Er startup2")
  377.         if fs.exists("startup2") then
  378.             shell.run("rm startup")
  379.             shell.run("mv startup2 startup")
  380.         end
  381.         os.reboot()
  382.     elseif num == 2 then
  383.         clear()
  384.         break
  385.     end
  386. end
  387. clear()
  388. print("Attendere")
  389. term.setTextColor(colors.black)
  390. shell.run("pastebin get 87bE40Er startup2")
  391. if fs.exists("startup2") then
  392.     shell.run("rm startup")
  393.     shell.run("mv startup2 startup")
  394. end
  395. os.reboot() -- Versamenti GELATI
  396. local maxw, maxh = term.getSize()
  397.  
  398. -- vuota il bancomat
  399. ben = peripheral.wrap("back")
  400. ben.getAvailableItems()
  401. i, j = os.pullEvent("available_items_return")
  402.  
  403. conoStracciatella = 0
  404. conoFiordilatte = 0
  405. conoCioccolato = 0
  406.  
  407. conoStracciatellaID = ben.getItemIdentifierIDFor(10292, 0)
  408. conoFiordilatteID = ben.getItemIdentifierIDFor(10293, 0)
  409. conoCioccolatoID = ben.getItemIdentifierIDFor(10290, 0)
  410.  
  411. for k, v in pairs(j) do
  412.     if v[1] == conoStracciatellaID then
  413.         conoStracciatella = v[2]
  414.         ben.makeRequest(conoStracciatellaID, v[2])
  415.  
  416.     elseif v[1] == conoFiordilatteID then
  417.         conoFiordilatte = v[2]
  418.         ben.makeRequest(conoFiordilatteID, v[2])
  419.  
  420.     elseif v[1] == conoCioccolatoID then
  421.         conoCioccolato = v[2]
  422.         ben.makeRequest(conoCioccolatoID, v[2])
  423.         sleep(0.1)
  424.     end
  425. end
  426.  
  427. ben.getAvailableItems()
  428. i, j = os.pullEvent("available_items_return")
  429.  
  430. conoStracciatellaID = ben.getItemIdentifierIDFor(10292, 0)
  431. conoFiordilatteID = ben.getItemIdentifierIDFor(10293, 0)
  432. conoCioccolatoID = ben.getItemIdentifierIDFor(10290, 0)
  433.  
  434. for k, v in pairs(j) do
  435.     if v[1] == conoStracciatellaID then
  436.         conoStracciatella = v[2]
  437.         ben.makeRequest(conoStracciatellaID, v[2])
  438.  
  439.     elseif v[1] == conoFiordilatteID then
  440.         conoFiordilatte = v[2]
  441.         ben.makeRequest(conoFiordilatteID, v[2])
  442.  
  443.     elseif v[1] == conoCioccolatoID then
  444.         conoCioccolato = v[2]
  445.         ben.makeRequest(conoCioccolatoID, v[2])
  446.         sleep(0.1)
  447.     end
  448. end
  449.  
  450. function clear()
  451.     term.clear()
  452.     term.setCursorPos(1, 1)
  453. end
  454.  
  455. if conoStracciatella ~= 0 or conoFiordilatte ~= 0 or conoCioccolato then
  456.     clear()
  457.     print("Bancomat temporaneamente non disponibile")
  458.     sleep(60)
  459.     os.reboot()
  460. end
  461.  
  462. function clear()
  463.     term.clear()
  464.     term.setCursorPos(1, 1)
  465. end
  466.  
  467. function clearRed()
  468.     sfondo(colors.red)
  469.     term.clear()
  470.     term.setCursorPos(1, 1)
  471. end
  472.  
  473. function colore(sfumatura) term.setTextColour(sfumatura) end
  474.  
  475. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  476.  
  477. function fineColore() term.setTextColour(colours.white) end
  478.  
  479. function fineSfondo() term.setBackgroundColour(colours.black) end
  480.  
  481. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  482. local function drawPixelInternal(xPos, yPos)
  483.     term.setCursorPos(xPos, yPos)
  484.     term.write(" ")
  485. end
  486.  
  487. local tColourLookup = {}
  488. for n = 1, 16 do
  489.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  490. end
  491.  
  492. function drawFilledBox(startX, startY, endX, endY, nColour)
  493.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  494.         "number" or type(endY) ~= "number" or
  495.         (nColour ~= nil and type(nColour) ~= "number") then
  496.         error("Expected startX, startY, endX, endY, colour", 2)
  497.     end
  498.  
  499.     startX = math.floor(startX)
  500.     startY = math.floor(startY)
  501.     endX = math.floor(endX)
  502.     endY = math.floor(endY)
  503.  
  504.     if nColour then term.setBackgroundColor(nColour) end
  505.     if startX == endX and startY == endY then
  506.         drawPixelInternal(startX, startY)
  507.         return
  508.     end
  509.  
  510.     local minX = math.min(startX, endX)
  511.     if minX == startX then
  512.         minY = startY
  513.         maxX = endX
  514.         maxY = endY
  515.     else
  516.         minY = endY
  517.         maxX = startX
  518.         maxY = startY
  519.     end
  520.  
  521.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  522. end
  523.  
  524. function titolo(testo)
  525.     drawFilledBox(1, 1, maxw, 1, colors.yellow)
  526.     term.setCursorPos((maxw - #testo) / 2, 1)
  527.     colore(colors.black)
  528.     term.write(testo)
  529.     sfondo(colors.blue)
  530. end
  531.  
  532. function errore(errore)
  533.     sfondo(colors.red)
  534.     colore(colors.white)
  535.     term.clear()
  536.     term.setCursorPos(1, 1)
  537.     titolo("Errore irreversibile")
  538.     term.setCursorPos(1, 3)
  539.     sfondo(colors.red)
  540.     colore(colors.white)
  541.     print(errore)
  542.     print("\n\n\nAttendere qualche secondo...")
  543.     os.sleep(5)
  544.     os.reboot()
  545. end
  546.  
  547. clear()
  548. print("FRIGOR - VENDITA GELATI")
  549. print("")
  550. print("Premere un tasto per iniziare l'operazione")
  551. print("")
  552. colore(colors.orange)
  553. print("ATTENZIONE AVVERTENZA MOLTO IMPORTANTE")
  554. print("1. Accetta SOLO coni gelati. NO vaschette!")
  555. print(
  556.     "2. In caso di utilizzo del deep, SI DEVE ATTENDERE CHE LO STESSO SIA COMPLETAMENTE VUOTO PRIMA DI PREMERE TASTI SUL COMPUTER.")
  557. print(
  558.     "   Per versare usando il deep, piazzarlo davanti al cubo rosso ED ATTENDERE CHE SIA VUOTO")
  559. print(
  560.     "   In caso contrario il gelato versato verrà distrutto irrimediabilmente!")
  561. event = os.pullEvent()
  562.  
  563. sfondo(colours.blue)
  564. term.clear()
  565. term.setCursorPos(1, 1)
  566. titolo("Accredita su Nebraska Pay")
  567. sfondo(colours.blue)
  568. colore(colors.white)
  569. print(
  570.     "\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.")
  571.  
  572. -- nomeutente
  573. term.setCursorPos(1, 9)
  574. term.write("Nome utente:")
  575. term.setCursorPos(15, 9)
  576. fineColore()
  577. utenteAccettato = false
  578. conteggioErrori = 0
  579. while utenteAccettato == false do
  580.     utente = read()
  581.     utente = string.gsub(utente, "%s", "")
  582.     checkuser = http.get(
  583.                     "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" ..
  584.                         utente).readAll()
  585.     tabcheckuser = textutils.unserialize(checkuser)
  586.     if tabcheckuser.stato == "OK" then
  587.         term.setCursorPos(15, 9)
  588.         colore(colours.lime)
  589.         term.write(utente)
  590.         fineColore()
  591.         utenteAccettato = true
  592.     else
  593.         term.setCursorPos(15, 9)
  594.         colore(colours.red)
  595.         term.write("Utente errato!          ")
  596.         sleep(2)
  597.         term.setCursorPos(15, 9)
  598.         fineColore()
  599.         term.write("                       ")
  600.         term.setCursorPos(15, 9)
  601.         conteggioErrori = conteggioErrori + 1
  602.         if conteggioErrori > 2 then
  603.             term.setCursorPos(15, 9)
  604.             colore(colours.red)
  605.             errore("Troppi tentativi di immissione errati    ")
  606.         end
  607.     end
  608. end
  609. colore(colours.white)
  610. term.setCursorPos(1, 11)
  611. term.write("Password:")
  612. term.setCursorPos(15, 11)
  613. conteggioErrori = 0
  614. passAccettata = false
  615. while passAccettata == false do
  616.     fineColore()
  617.     password = read("#")
  618.     colore(colours.black)
  619.     checkuser = http.get(
  620.                     "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" ..
  621.                         password .. "&richiesta=addebito&valore=0&utente=" ..
  622.                         utente).readAll()
  623.     risposta = textutils.unserialize(checkuser)
  624.     if risposta.stato == "OK" then
  625.         term.setCursorPos(15, 11)
  626.         colore(colours.lime)
  627.         term.write("##############               ")
  628.         fineColore()
  629.         passAccettata = true
  630.     else
  631.         term.setCursorPos(15, 11)
  632.         colore(colours.red)
  633.         term.write("Password errata!            ")
  634.         conteggioErrori = conteggioErrori + 1
  635.         sleep(2)
  636.         term.setCursorPos(15, 11)
  637.         term.write("                               ")
  638.         term.setCursorPos(15, 11)
  639.         if conteggioErrori > 2 then
  640.             term.setCursorPos(15, 11)
  641.             colore(colours.red)
  642.             errore("Troppi tentativi di immissione errati")
  643.         end
  644.     end
  645. end
  646. metodoPagamento = "NPAY"
  647. credito = tonumber(risposta.saldo)
  648. clear()
  649.  
  650. while true do
  651.     print("Il conto ha un saldo di " .. credito .. " IC.")
  652.     print("")
  653.     print(
  654.         "Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
  655.     print("")
  656.     print("[1] Versare dei gelati")
  657.     print("[2] Annullare il versamento")
  658.  
  659.     num = tonumber(read())
  660.     if num == 1 then
  661.  
  662.         clear()
  663.         redstone.setOutput("left", true)
  664.         print(
  665.             "Inserire i gelati nello sportello a destra oppure collocare il Deep Storage di fronte al cubo rosso o posizionare")
  666.         print("")
  667.         print("AVVERTENZA IMPORTANTE:")
  668.         print("Inserire SOLO questi gelati:")
  669.         print(
  670.             "Cono stracciatella, cono fiordilatte, gelato cioccolato, gelato stracciatella, gelato fiordilatte")
  671.         print("")
  672.         print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
  673.         print("")
  674.         print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
  675.         os.pullEvent("key")
  676.  
  677.         clear()
  678.  
  679.         redstone.setOutput("left", false)
  680.  
  681.         print("Conteggio gelati in corso...")
  682.  
  683.         term.setCursorPos(3, 3)
  684.         term.write("*---")
  685.         sleep(0.5)
  686.         term.setCursorPos(3, 3)
  687.         term.write("-*--")
  688.         sleep(0.5)
  689.         term.setCursorPos(3, 3)
  690.         term.write("--*-")
  691.         sleep(0.5)
  692.         term.setCursorPos(3, 3)
  693.         term.write("---*")
  694.         sleep(0.5)
  695.         term.setCursorPos(3, 3)
  696.         term.write("--*-")
  697.         sleep(0.5)
  698.         term.setCursorPos(3, 3)
  699.         term.write("-*--")
  700.         sleep(0.5)
  701.         term.setCursorPos(3, 3)
  702.         term.write("*---")
  703.         sleep(0.5)
  704.  
  705.         ben = peripheral.wrap("back")
  706.         ben.getAvailableItems()
  707.         i, j = os.pullEvent("available_items_return")
  708.  
  709.         clear()
  710.  
  711.         conoStracciatellaID = ben.getItemIdentifierIDFor(10292, 0)
  712.         conoFiordilatteID = ben.getItemIdentifierIDFor(10293, 0)
  713.         conoCioccolatoID = ben.getItemIdentifierIDFor(10290, 0)
  714.  
  715.         for k, v in pairs(j) do
  716.             if v[1] == conoStracciatellaID then
  717.                 conoStracciatella = v[2]
  718.                 ben.makeRequest(conoStracciatellaID, v[2])
  719.  
  720.             elseif v[1] == conoFiordilatteID then
  721.                 conoFiordilatte = v[2]
  722.                 ben.makeRequest(conoFiordilatteID, v[2])
  723.  
  724.             elseif v[1] == conoCioccolatoID then
  725.                 conoCioccolato = v[2]
  726.                 ben.makeRequest(conoCioccolatoID, v[2])
  727.                 sleep(0.1)
  728.             end
  729.         end
  730.  
  731.         conoStracciatellaIC = conoStracciatella * 0.45
  732.         conoFiordilatteIC = conoFiordilatte * 0.43
  733.         conoCioccolatoIC = conoCioccolato * 0.49
  734.  
  735.         contanti = conoStracciatellaIC + conoFiordilatteIC + conoCioccolatoIC
  736.  
  737.         print("Totale versato: " .. contanti .. " IC")
  738.         print("")
  739.         inviaDenaro = http.get(
  740.                           "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" ..
  741.                               password .. "&utente=" .. utente ..
  742.                               "&richiesta=accredito&valore=" .. contanti)
  743.                           .readAll()
  744.         risultatoInvio = textutils.unserialize(inviaDenaro)
  745.         if risultatoInvio.stato == "OK" then
  746.             colore(colors.white)
  747.         else
  748.             clear()
  749.             errore("Errore durante il pagamento")
  750.             sleep(5)
  751.             os.reboot()
  752.         end
  753.         if tonumber(contanti) ~= 0 then
  754.             inviaFisco = http.get(
  755.                              "http://172.16.20.220/luanet/servlets/fisco.php?msg=" ..
  756.                                  contanti .. "%20IC%20di%20gelati%20-%20" ..
  757.                                  utente)
  758.             inviaDGFE = http.get(
  759.                             "http://172.16.20.220/luanet/servlets/dgfe.php?npay_user=" ..
  760.                                 utente ..
  761.                                 "&transaction_type=Gelati%20Frigor&transaction_amount=" ..
  762.                                 contanti)
  763.         end
  764.         sleep(1)
  765.         clear()
  766.         print("Denaro versato.")
  767.         print("")
  768.         print("")
  769.         print("Grazie!")
  770.         sleep(1)
  771.         term.setTextColor(colors.black)
  772.         shell.run("pastebin get 87bE40Er startup2")
  773.         if fs.exists("startup2") then
  774.             shell.run("rm startup")
  775.             shell.run("mv startup2 startup")
  776.         end
  777.         os.reboot()
  778.     elseif num == 2 then
  779.         clear()
  780.         break
  781.     end
  782. end
  783. clear()
  784. print("Attendere")
  785. term.setTextColor(colors.black)
  786. shell.run("pastebin get 87bE40Er startup2")
  787. if fs.exists("startup2") then
  788.     shell.run("rm startup")
  789.     shell.run("mv startup2 startup")
  790. end
  791. os.reboot()
  792.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement