SHOW:
|
|
- or go back to the newest paste.
| 1 | local maxw, maxh = term.getSize() | |
| 2 | ||
| 3 | lato = "bottom" | |
| 4 | ||
| 5 | soldi = 100 | |
| 6 | ||
| 7 | ||
| 8 | rs.setOutput(lato, false) | |
| 9 | ||
| 10 | ||
| 11 | ||
| 12 | -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
| 13 | local function drawPixelInternal(xPos, yPos) | |
| 14 | term.setCursorPos(xPos, yPos) | |
| 15 | term.write(" ")
| |
| 16 | end | |
| 17 | ||
| 18 | local tColourLookup = {}
| |
| 19 | for n = 1, 16 do | |
| 20 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 21 | end | |
| 22 | ||
| 23 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 24 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
| 25 | "number" or type(endY) ~= "number" or | |
| 26 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 27 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 28 | end | |
| 29 | ||
| 30 | startX = math.floor(startX) | |
| 31 | startY = math.floor(startY) | |
| 32 | endX = math.floor(endX) | |
| 33 | endY = math.floor(endY) | |
| 34 | ||
| 35 | if nColour then term.setBackgroundColor(nColour) end | |
| 36 | if startX == endX and startY == endY then | |
| 37 | drawPixelInternal(startX, startY) | |
| 38 | return | |
| 39 | end | |
| 40 | ||
| 41 | local minX = math.min(startX, endX) | |
| 42 | if minX == startX then | |
| 43 | minY = startY | |
| 44 | maxX = endX | |
| 45 | maxY = endY | |
| 46 | else | |
| 47 | minY = endY | |
| 48 | maxX = startX | |
| 49 | maxY = startY | |
| 50 | end | |
| 51 | ||
| 52 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
| 53 | end | |
| 54 | ||
| 55 | function colore(nome) term.setTextColor(nome) end | |
| 56 | ||
| 57 | function sfondo(nome) term.setBackgroundColor(nome) end | |
| 58 | ||
| 59 | function fineColore() term.setTextColour(colours.white) end | |
| 60 | ||
| 61 | function fineSfondo() term.setBackgroundColour(colours.black) end | |
| 62 | ||
| 63 | function titolo(testo) | |
| 64 | drawFilledBox(1, 1, maxw, 1, colors.blue) | |
| 65 | term.setCursorPos((maxw - #testo) / 2, 1) | |
| 66 | colore(colors.white) | |
| 67 | term.write(testo) | |
| 68 | sfondo(colors.white) | |
| 69 | end | |
| 70 | ||
| 71 | function clear() | |
| 72 | sfondo(colors.blue) | |
| 73 | term.clear() | |
| 74 | term.setCursorPos(1, 1) | |
| 75 | end | |
| 76 | ||
| 77 | function errore(errore) | |
| 78 | sfondo(colors.red) | |
| 79 | colore(colors.white) | |
| 80 | term.clear() | |
| 81 | term.setCursorPos(1, 1) | |
| 82 | titolo("Errore irreversibile")
| |
| 83 | term.setCursorPos(1, 3) | |
| 84 | sfondo(colors.red) | |
| 85 | colore(colors.white) | |
| 86 | term.setCursorPos(16, 10) | |
| 87 | term.write("Sei un poraccio...")
| |
| 88 | os.sleep(5) | |
| 89 | os.reboot() | |
| 90 | end | |
| 91 | ||
| 92 | clear() | |
| 93 | sfondo(colors.lightBlue) | |
| 94 | colore(colors.black) | |
| 95 | term.setCursorPos(1, 1) | |
| 96 | titolo("Zona XP")
| |
| 97 | term.setCursorPos(1, 3) | |
| 98 | ||
| 99 | ||
| 100 | drawFilledBox(13, 9, 35, 11, colors.white) | |
| 101 | colore(colors.red) | |
| 102 | term.setCursorPos(15, 10) | |
| 103 | term.write("Entra nella zona XP")
| |
| 104 | ||
| 105 | ||
| 106 | ||
| 107 | while true do | |
| 108 | local event, par1, par2, par3 = os.pullEvent("mouse_click")
| |
| 109 | if par2 >= 20 and par2 <= 27 and par3 >= 10 and par3 <= 12 then -- Utenti | |
| 110 | ||
| 111 | clear() | |
| 112 | term.clear() | |
| 113 | fineSfondo() | |
| 114 | titolo("Login nPay XP zone")
| |
| 115 | sfondo(colors.lightBlue) | |
| 116 | colore(colors.white) | |
| 117 | term.setCursorPos(1, 3) | |
| 118 | print("Inserire i propri dati.")
| |
| 119 | colore(colors.gray) | |
| 120 | print("\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA0 verde.\nSe sono errati, il programma chiederåA0 di reinserirli nuovamente.")
| |
| 121 | ||
| 122 | --nomeutente | |
| 123 | term.setCursorPos(1, 10) | |
| 124 | colore(colors.black) | |
| 125 | term.write("Nome utente:")
| |
| 126 | term.setCursorPos(15, 10) | |
| 127 | colore(colors.white) | |
| 128 | utenteAccettato = false | |
| 129 | conteggioErrori = 0 | |
| 130 | while utenteAccettato == false do | |
| 131 | utente = read() | |
| 132 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente="..utente).readAll()
| |
| 133 | tabcheckuser = textutils.unserialize(checkuser) | |
| 134 | if tabcheckuser.stato == "OK" then | |
| 135 | term.setCursorPos(15, 10) | |
| 136 | colore(colors.lime) | |
| 137 | term.write(utente) | |
| 138 | colore(colors.white) | |
| 139 | utenteAccettato = true | |
| 140 | else | |
| 141 | term.setCursorPos(15, 10) | |
| 142 | colore(colors.red) | |
| 143 | term.write("Utente errato!")
| |
| 144 | sleep(2) | |
| 145 | term.setCursorPos(15, 10) | |
| 146 | colore(colors.white) | |
| 147 | term.write(" ")
| |
| 148 | term.setCursorPos(15, 10) | |
| 149 | conteggioErrori = conteggioErrori + 1 | |
| 150 | if conteggioErrori > 2 then | |
| 151 | term.setCursorPos(15, 10) | |
| 152 | colore(colors.red) | |
| 153 | term.write("Tre tentativi di immissione errati.")
| |
| 154 | sleep(2) | |
| 155 | term.setCursorPos(15, 10) | |
| 156 | colore(colors.white) | |
| 157 | term.write(" ")
| |
| 158 | term.setCursorPos(15, 10) | |
| 159 | clear() | |
| 160 | os.reboot() | |
| 161 | end | |
| 162 | end | |
| 163 | end | |
| 164 | ||
| 165 | --password | |
| 166 | colore(colors.black) | |
| 167 | term.setCursorPos(1,12) | |
| 168 | term.write("Password:")
| |
| 169 | term.setCursorPos(15, 12) | |
| 170 | ||
| 171 | conteggioErrori = 0 | |
| 172 | passAccettata = false | |
| 173 | while passAccettata == false do | |
| 174 | colore(colors.white) | |
| 175 | password = read("#")
| |
| 176 | colore(colors.black) | |
| 177 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
| |
| 178 | risposta = textutils.unserialize(checkuser) | |
| 179 | if risposta.stato == "OK" then | |
| 180 | term.setCursorPos(15, 12) | |
| 181 | colore(colors.lime) | |
| 182 | term.write("##############")
| |
| 183 | colore(colors.white) | |
| 184 | passAccettata = true | |
| 185 | else | |
| 186 | term.setCursorPos(15, 12) | |
| 187 | colore(colors.red) | |
| 188 | term.write("Password errata!")
| |
| 189 | conteggioErrori = conteggioErrori + 1 | |
| 190 | sleep(2) | |
| 191 | term.setCursorPos(15, 12) | |
| 192 | term.write(" ")
| |
| 193 | term.setCursorPos(15, 12) | |
| 194 | if conteggioErrori > 2 then | |
| 195 | term.setCursorPos(15, 12) | |
| 196 | colore(colors.red) | |
| 197 | term.write("Tre tentativi di immissione errati.")
| |
| 198 | sleep(2) | |
| 199 | term.setCursorPos(15, 12) | |
| 200 | term.write(" ")
| |
| 201 | term.setCursorPos(15, 12) | |
| 202 | clear() | |
| 203 | os.reboot() | |
| 204 | end | |
| 205 | end | |
| 206 | end | |
| 207 | ||
| 208 | while true do | |
| 209 | ||
| 210 | --Ricontrolla il saldo per gestire l'aggiornamento di piåA5A5B9 operazioni | |
| 211 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
| |
| 212 | risposta = textutils.unserialize(checkuser) | |
| 213 | saldo = tonumber(risposta.saldo) | |
| 214 | --Disegna la finestra del pannello utente | |
| 215 | clear() | |
| 216 | titolo("Pannello utente nPay")
| |
| 217 | sfondo(colors.lightBlue) | |
| 218 | colore(colors.black) | |
| 219 | term.setCursorPos(1, 3) | |
| 220 | term.write("Benvenuto, ")
| |
| 221 | colore(colors.white) | |
| 222 | term.write(utente) | |
| 223 | colore(colors.black) | |
| 224 | term.write("! Saldo: ")
| |
| 225 | colore(colors.white) | |
| 226 | term.write(saldo) | |
| 227 | colore(colors.black) | |
| 228 | term.write(" IC")
| |
| 229 | print("\n\nOperazioni disponibili:\n")
| |
| 230 | sfondo(colors.lightBlue) | |
| 231 | colore(colors.white) | |
| 232 | print(" Paga 100IC per entrare \n")
| |
| 233 | colore(colors.red) | |
| 234 | print(" Disconnettiti da Npay \n")
| |
| 235 | colore(colors.black) | |
| 236 | ||
| 237 | antitonto = os.startTimer(60) | |
| 238 | ||
| 239 | event, key, x, y = os.pullEventRaw() | |
| 240 | if event == "mouse_click" and y == 7 and x <= 24 then --Pulsante carica denaro su nPay | |
| 241 | clear() | |
| 242 | titolo("Apertura porta")
| |
| 243 | if(saldo>=soldi) then | |
| 244 | - | inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. "100" .. "&beneficiario=" .. "eternalcaos").readAll()
|
| 244 | + | inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. "100" .. "&beneficiario=" .. "eternal").readAll()
|
| 245 | risultatoInvio = textutils.unserialize(inviaDenaro) | |
| 246 | if risultatoInvio.stato == "OK" then | |
| 247 | term.setCursorPos(1, 10) | |
| 248 | colore(colors.red) | |
| 249 | rs.setOutput(lato, false) | |
| 250 | print("Soldi scalati")
| |
| 251 | print("Corri prima che sia tardi ;)")
| |
| 252 | rs.setOutput("right", true)
| |
| 253 | sleep(0.5) | |
| 254 | rs.setOutput("right", false)
| |
| 255 | sleep(2) | |
| 256 | rs.setOutput(lato, true) | |
| 257 | sleep(10) | |
| 258 | rs.setOutput("right", true)
| |
| 259 | sleep(0.5) | |
| 260 | rs.setOutput("right", false)
| |
| 261 | os.reboot() | |
| 262 | else | |
| 263 | term.setCursorPos(1, 10) | |
| 264 | colore(colors.red) | |
| 265 | term.write("Che culo :(")
| |
| 266 | end | |
| 267 | sleep(1) | |
| 268 | ||
| 269 | ||
| 270 | else | |
| 271 | errore("poraccio")
| |
| 272 | end | |
| 273 | ||
| 274 | else if event == "mouse_click" and y == 10 and x <= 31 then | |
| 275 | os.sleep(1) | |
| 276 | os.reboot() | |
| 277 | ||
| 278 | end | |
| 279 | ||
| 280 | end | |
| 281 | ||
| 282 | ||
| 283 | end | |
| 284 | ||
| 285 | end | |
| 286 | ||
| 287 | end |