SHOW:
|
|
- or go back to the newest paste.
| 1 | local maxw, maxh = term.getSize() | |
| 2 | ||
| 3 | function creditoInsufficiente() | |
| 4 | clearRed() | |
| 5 | print("Credito insufficiente.")
| |
| 6 | print("")
| |
| 7 | print("Premere un tasto per uscire")
| |
| 8 | os.pullEvent("key")
| |
| 9 | os.reboot() | |
| 10 | end | |
| 11 | ||
| 12 | function prodottoEsaurito() | |
| 13 | clearRed() | |
| 14 | print("Prodotto esaurito.")
| |
| 15 | print("")
| |
| 16 | print("Premere un tasto per uscire")
| |
| 17 | os.pullEvent("key")
| |
| 18 | os.reboot() | |
| 19 | end | |
| 20 | ||
| 21 | -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
| 22 | local function drawPixelInternal(xPos, yPos) | |
| 23 | term.setCursorPos(xPos, yPos) | |
| 24 | term.write(" ")
| |
| 25 | end | |
| 26 | ||
| 27 | local tColourLookup = {}
| |
| 28 | for n = 1, 16 do | |
| 29 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 30 | end | |
| 31 | ||
| 32 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 33 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
| 34 | "number" or type(endY) ~= "number" or | |
| 35 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 36 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 37 | end | |
| 38 | ||
| 39 | startX = math.floor(startX) | |
| 40 | startY = math.floor(startY) | |
| 41 | endX = math.floor(endX) | |
| 42 | endY = math.floor(endY) | |
| 43 | ||
| 44 | if nColour then term.setBackgroundColor(nColour) end | |
| 45 | if startX == endX and startY == endY then | |
| 46 | drawPixelInternal(startX, startY) | |
| 47 | return | |
| 48 | end | |
| 49 | ||
| 50 | local minX = math.min(startX, endX) | |
| 51 | if minX == startX then | |
| 52 | minY = startY | |
| 53 | maxX = endX | |
| 54 | maxY = endY | |
| 55 | else | |
| 56 | minY = endY | |
| 57 | maxX = startX | |
| 58 | maxY = startY | |
| 59 | end | |
| 60 | ||
| 61 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
| 62 | end | |
| 63 | ||
| 64 | function clear() | |
| 65 | sfondo(colors.black) | |
| 66 | term.clear() | |
| 67 | term.setCursorPos(1, 1) | |
| 68 | end | |
| 69 | ||
| 70 | function clearRed() | |
| 71 | sfondo(colors.red) | |
| 72 | term.clear() | |
| 73 | term.setCursorPos(1, 1) | |
| 74 | end | |
| 75 | ||
| 76 | function colore(sfumatura) term.setTextColour(sfumatura) end | |
| 77 | ||
| 78 | function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end | |
| 79 | ||
| 80 | function fineColore() term.setTextColour(colours.white) end | |
| 81 | ||
| 82 | function fineSfondo() term.setBackgroundColour(colours.black) end | |
| 83 | ||
| 84 | function titolo(testo) | |
| 85 | drawFilledBox(1, 1, maxw, 1, colors.yellow) | |
| 86 | term.setCursorPos((maxw - #testo) / 2, 1) | |
| 87 | colore(colors.black) | |
| 88 | term.write(testo) | |
| 89 | sfondo(colors.blue) | |
| 90 | end | |
| 91 | ||
| 92 | function errore(errore) | |
| 93 | sfondo(colors.red) | |
| 94 | colore(colors.white) | |
| 95 | term.clear() | |
| 96 | term.setCursorPos(1, 1) | |
| 97 | titolo("Errore irreversibile")
| |
| 98 | term.setCursorPos(1, 3) | |
| 99 | sfondo(colors.red) | |
| 100 | colore(colors.white) | |
| 101 | print(errore) | |
| 102 | print("\n\n\nAttendere qualche secondo...")
| |
| 103 | os.sleep(5) | |
| 104 | os.reboot() | |
| 105 | end | |
| 106 | ||
| 107 | sfondo(colours.blue) | |
| 108 | term.clear() | |
| 109 | term.setCursorPos(1, 1) | |
| 110 | titolo("Pagamento rapido con Nebraska Pay")
| |
| 111 | sfondo(colours.blue) | |
| 112 | colore(colors.white) | |
| 113 | print( | |
| 114 | "\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.") | |
| 115 | ||
| 116 | -- nomeutente | |
| 117 | term.setCursorPos(1, 9) | |
| 118 | term.write("Nome utente:")
| |
| 119 | term.setCursorPos(15, 9) | |
| 120 | fineColore() | |
| 121 | utenteAccettato = false | |
| 122 | conteggioErrori = 0 | |
| 123 | while utenteAccettato == false do | |
| 124 | utente = read() | |
| 125 | checkuser = http.get( | |
| 126 | "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. | |
| 127 | utente).readAll() | |
| 128 | tabcheckuser = textutils.unserialize(checkuser) | |
| 129 | if tabcheckuser.stato == "OK" then | |
| 130 | term.setCursorPos(15, 9) | |
| 131 | colore(colours.lime) | |
| 132 | term.write(utente) | |
| 133 | fineColore() | |
| 134 | utenteAccettato = true | |
| 135 | else | |
| 136 | term.setCursorPos(15, 9) | |
| 137 | colore(colours.red) | |
| 138 | term.write("Utente errato! ")
| |
| 139 | sleep(2) | |
| 140 | term.setCursorPos(15, 9) | |
| 141 | fineColore() | |
| 142 | term.write(" ")
| |
| 143 | term.setCursorPos(15, 9) | |
| 144 | conteggioErrori = conteggioErrori + 1 | |
| 145 | if conteggioErrori > 2 then | |
| 146 | term.setCursorPos(15, 9) | |
| 147 | colore(colours.red) | |
| 148 | errore("Troppi tentativi di immissione errati ")
| |
| 149 | end | |
| 150 | end | |
| 151 | end | |
| 152 | colore(colours.white) | |
| 153 | term.setCursorPos(1, 11) | |
| 154 | term.write("Password:")
| |
| 155 | term.setCursorPos(15, 11) | |
| 156 | conteggioErrori = 0 | |
| 157 | passAccettata = false | |
| 158 | while passAccettata == false do | |
| 159 | fineColore() | |
| 160 | password = read("#")
| |
| 161 | colore(colours.black) | |
| 162 | checkuser = http.get( | |
| 163 | "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. | |
| 164 | password .. "&richiesta=addebito&valore=0&utente=" .. | |
| 165 | utente).readAll() | |
| 166 | risposta = textutils.unserialize(checkuser) | |
| 167 | if risposta.stato == "OK" then | |
| 168 | term.setCursorPos(15, 11) | |
| 169 | colore(colours.lime) | |
| 170 | term.write("############## ")
| |
| 171 | fineColore() | |
| 172 | passAccettata = true | |
| 173 | else | |
| 174 | term.setCursorPos(15, 11) | |
| 175 | colore(colours.red) | |
| 176 | term.write("Password errata! ")
| |
| 177 | conteggioErrori = conteggioErrori + 1 | |
| 178 | sleep(2) | |
| 179 | term.setCursorPos(15, 11) | |
| 180 | term.write(" ")
| |
| 181 | term.setCursorPos(15, 11) | |
| 182 | if conteggioErrori > 2 then | |
| 183 | term.setCursorPos(15, 11) | |
| 184 | colore(colours.red) | |
| 185 | errore("Troppi tentativi di immissione errati")
| |
| 186 | end | |
| 187 | end | |
| 188 | end | |
| 189 | ||
| 190 | while true do | |
| 191 | clear() | |
| 192 | - | titolo("HIGHLAND MINING ")
|
| 192 | + | titolo("HIGHLAND QUARRIES ")
|
| 193 | colore(colors.white) | |
| 194 | sfondo(colors.red) | |
| 195 | term.setCursorPos(35, 1) | |
| 196 | term.write(" CHIUDI SESSIONE ")
| |
| 197 | fineColore() | |
| 198 | fineSfondo() | |
| 199 | print("")
| |
| 200 | print("\nProdotto Prezzo")
| |
| 201 | p = {}
| |
| 202 | -- nome, prezzo, id, meta, colore cavo | |
| 203 | - | p[1] = {"Rame", 980, 2001, 0, 1}
|
| 203 | + | p[1] = {"Tufo", 212, 146, 6, 1}
|
| 204 | - | p[2] = {"Ferro", 1024, 15, 0, 2}
|
| 204 | + | p[2] = {"Peridotite", 300, 146, 3, 2}
|
| 205 | - | p[3] = {"Carbone", 50, 263, 0, 4}
|
| 205 | + | p[3] = {"Diaspro", 140, 146, 5, 4}
|
| 206 | ||
| 207 | ypos = 4 | |
| 208 | for k, v in pairs(p) do | |
| 209 | term.setCursorPos(1, ypos) | |
| 210 | term.write(v[1]) | |
| 211 | term.setCursorPos(20, ypos) | |
| 212 | term.write(v[2]) | |
| 213 | term.setCursorPos(30, ypos) | |
| 214 | if alt == false then | |
| 215 | sfondo(colors.lightBlue) | |
| 216 | alt = true | |
| 217 | else | |
| 218 | sfondo(colors.blue) | |
| 219 | alt = false | |
| 220 | end | |
| 221 | colore(colors.white) | |
| 222 | term.write(" Compra ")
| |
| 223 | fineSfondo() | |
| 224 | fineColore() | |
| 225 | ypos = ypos + 1 | |
| 226 | end | |
| 227 | ||
| 228 | while true do | |
| 229 | ||
| 230 | local event, par1, x, y = os.pullEvent("mouse_click")
| |
| 231 | if event == "mouse_click" and y > 3 and y < 7 then | |
| 232 | prodotto = p[y - 3] | |
| 233 | break | |
| 234 | elseif event == "mouse_click" and y == 1 then | |
| 235 | os.reboot() | |
| 236 | end | |
| 237 | sleep(1) | |
| 238 | end | |
| 239 | clear() | |
| 240 | ||
| 241 | print(prodotto[1]) | |
| 242 | ||
| 243 | if colors.test(redstone.getBundledInput("bottom"), prodotto[5]) == true then
| |
| 244 | prodottoEsaurito() | |
| 245 | end | |
| 246 | term.clear() | |
| 247 | term.setCursorPos(1, 1) | |
| 248 | titolo("Paga con Nebraska Pay")
| |
| 249 | sfondo(colours.black) | |
| 250 | colore(colors.white) | |
| 251 | print("\n\nSaldo disponibile: " .. risposta.saldo .. " IC")
| |
| 252 | if tonumber(risposta.saldo) >= tonumber(prodotto[2]) then | |
| 253 | prezzoAccettato = true | |
| 254 | else | |
| 255 | errore("Disponibilità insufficiente!")
| |
| 256 | end | |
| 257 | term.setCursorPos(1, 3) | |
| 258 | term.write("Invio di ")
| |
| 259 | term.write(prodotto[2]) | |
| 260 | term.write(" IC a favore di ")
| |
| 261 | term.write("Highland Mining")
| |
| 262 | print("\n\nConfermare l'operazione?")
| |
| 263 | colore(colors.yellow) | |
| 264 | print("\n\nInvia il denaro Annulla")
| |
| 265 | while true do | |
| 266 | event, key, x, y = os.pullEvent() | |
| 267 | if event == "mouse_click" and x < 16 and y == 8 then | |
| 268 | inviaDenaro = http.get( | |
| 269 | "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. | |
| 270 | password .. "&utente=" .. utente .. | |
| 271 | "&richiesta=trasferimento&valore=" .. | |
| 272 | - | prodotto[2] .. "&beneficiario=HighlandMining&causale=Merce%20ingrosso%20Karabash") |
| 272 | + | prodotto[2] .. "&beneficiario=HighlandMining&causale=Merce%20ingrosso%20Azarus") |
| 273 | .readAll() | |
| 274 | risultatoInvio = textutils.unserialize(inviaDenaro) | |
| 275 | if risultatoInvio.stato == "OK" then | |
| 276 | break | |
| 277 | else | |
| 278 | clear() | |
| 279 | errore("Errore durante il pagamento")
| |
| 280 | end | |
| 281 | elseif event == "mouse_click" and x > 18 and y == 8 then | |
| 282 | errore("Pagamento annullato dall'utente.")
| |
| 283 | end | |
| 284 | end | |
| 285 | clear() | |
| 286 | titolo("Erogazione in corso")
| |
| 287 | fineSfondo() | |
| 288 | fineColore() | |
| 289 | print("\n\nErogazione di un vagone di " .. prodotto[1] .. " in corso...")
| |
| 290 | print("\nATTENZIONE: IMPIANTO LOGISTIC LENTO, ATTENDERE")
| |
| 291 | sfondo(colors.red) | |
| 292 | colore(colors.white) | |
| 293 | ben = peripheral.wrap("back")
| |
| 294 | ben.makeRequest(ben.getItemIdentifierIDFor(prodotto[3], prodotto[4]), 3456) | |
| 295 | sleep(10) | |
| 296 | end | |
| 297 |