SHOW:
|
|
- or go back to the newest paste.
| 1 | -- funzioni helper di base | |
| 2 | local maxw, maxh = term.getSize() | |
| 3 | ||
| 4 | pl = peripheral.wrap("right")
| |
| 5 | sim = peripheral.wrap("left")
| |
| 6 | if fs.exists("json") == false then
| |
| 7 | shell.run("pastebin get RPUyCMjG json")
| |
| 8 | end | |
| 9 | ||
| 10 | os.loadAPI("json")
| |
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | function checkCredentials(player) | |
| 15 | if fs.exists("credentials") then
| |
| 16 | local credList = fs.open("credentials", "r")
| |
| 17 | if type(credList) == "table" then | |
| 18 | result = string.find(credList.readAll(), player) | |
| 19 | credList.close() | |
| 20 | if result == nil then | |
| 21 | return false | |
| 22 | else | |
| 23 | return true | |
| 24 | end | |
| 25 | else | |
| 26 | return false | |
| 27 | end | |
| 28 | else | |
| 29 | return false | |
| 30 | end | |
| 31 | return false | |
| 32 | end | |
| 33 | ||
| 34 | function addToCredentials(player) | |
| 35 | local credList = fs.open("credentials", "a")
| |
| 36 | credList.writeLine(player) | |
| 37 | credList.close() | |
| 38 | end | |
| 39 | ||
| 40 | function tablelength(T) | |
| 41 | local count = 0 | |
| 42 | for _ in pairs(T) do | |
| 43 | count = count + 1 | |
| 44 | end | |
| 45 | return count | |
| 46 | end | |
| 47 | ||
| 48 | function clear() | |
| 49 | term.clear() | |
| 50 | term.setCursorPos(1, 1) | |
| 51 | end | |
| 52 | ||
| 53 | function clearRed() | |
| 54 | sfondo(colors.red) | |
| 55 | term.clear() | |
| 56 | term.setCursorPos(1, 1) | |
| 57 | end | |
| 58 | ||
| 59 | function colore(sfumatura) | |
| 60 | term.setTextColour(sfumatura) | |
| 61 | end | |
| 62 | ||
| 63 | function sfondo(sfumaturaSfondo) | |
| 64 | term.setBackgroundColour(sfumaturaSfondo) | |
| 65 | end | |
| 66 | ||
| 67 | function fineColore() | |
| 68 | term.setTextColour(colours.white) | |
| 69 | end | |
| 70 | ||
| 71 | function fineSfondo() | |
| 72 | term.setBackgroundColour(colours.black) | |
| 73 | end | |
| 74 | ||
| 75 | -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
| 76 | local function drawPixelInternal(xPos, yPos) | |
| 77 | term.setCursorPos(xPos, yPos) | |
| 78 | term.write(" ")
| |
| 79 | end | |
| 80 | ||
| 81 | local tColourLookup = {}
| |
| 82 | for n = 1, 16 do | |
| 83 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 84 | end | |
| 85 | ||
| 86 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 87 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= "number" or type(endY) ~= "number" or | |
| 88 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 89 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 90 | end | |
| 91 | ||
| 92 | startX = math.floor(startX) | |
| 93 | - | drawFilledBox(1, 1, maxw, 1, bk) |
| 93 | + | |
| 94 | endX = math.floor(endX) | |
| 95 | - | colore(cl) |
| 95 | + | |
| 96 | ||
| 97 | if nColour then | |
| 98 | term.setBackgroundColor(nColour) | |
| 99 | end | |
| 100 | if startX == endX and startY == endY then | |
| 101 | drawPixelInternal(startX, startY) | |
| 102 | return | |
| 103 | end | |
| 104 | ||
| 105 | local minX = math.min(startX, endX) | |
| 106 | if minX == startX then | |
| 107 | minY = startY | |
| 108 | maxX = endX | |
| 109 | maxY = endY | |
| 110 | else | |
| 111 | minY = endY | |
| 112 | maxX = startX | |
| 113 | maxY = startY | |
| 114 | end | |
| 115 | ||
| 116 | for x = minX, maxX do | |
| 117 | for y = minY, maxY do | |
| 118 | drawPixelInternal(x, y) | |
| 119 | end | |
| 120 | - | sfondo(colors.magenta) |
| 120 | + | |
| 121 | end | |
| 122 | ||
| 123 | function titolo(testo, bk, cl) | |
| 124 | - | titolo("Highland Mobile", colors.purple, colors.white)
|
| 124 | + | drawFilledBox(1, 1, maxw, 1, colors.orange) |
| 125 | - | sfondo(colors.magenta) |
| 125 | + | |
| 126 | - | term.setCursorPos(2, 3) |
| 126 | + | colore(colors.black) |
| 127 | - | term.write("Ciao e benvenuto su RGBCraft!")
|
| 127 | + | |
| 128 | - | term.setCursorPos(2, 5) |
| 128 | + | |
| 129 | - | term.write("Noi siamo la , operatore")
|
| 129 | + | |
| 130 | - | term.setCursorPos(2, 6) |
| 130 | + | |
| 131 | - | term.write("statale di telefonia mobile.")
|
| 131 | + | function printCentered(text) |
| 132 | - | term.setCursorPos(2, 8) |
| 132 | + | curX, curY = term.getCursorPos() |
| 133 | - | term.write("Cliccando sul bottone sottotante potrai")
|
| 133 | + | term.setCursorPos((maxw - #text) / 2, curY) |
| 134 | - | term.setCursorPos(2, 9) |
| 134 | + | term.write(text) |
| 135 | - | term.write("richiedere la tua nuovissima SIM Card")
|
| 135 | + | |
| 136 | - | term.setCursorPos(2, 10) |
| 136 | + | |
| 137 | - | term.write("con il nostro piano scelto apposta per te!")
|
| 137 | + | |
| 138 | - | term.setCursorPos(2, 12) |
| 138 | + | |
| 139 | - | term.write("Piano personalizzato: Simple20")
|
| 139 | + | |
| 140 | - | drawFilledBox(8, 15, 42, 17, colors.purple) |
| 140 | + | |
| 141 | - | term.setCursorPos(16, 16) |
| 141 | + | |
| 142 | - | term.write("Avvia la procedura!")
|
| 142 | + | |
| 143 | - | sfondo(colors.purple) |
| 143 | + | |
| 144 | - | term.setCursorPos(15, 5) |
| 144 | + | |
| 145 | - | term.write("Highland MobileTM")
|
| 145 | + | |
| 146 | print(errore) | |
| 147 | - | titolo("Richiedi una SIM Card", colors.purple, colors.white)
|
| 147 | + | |
| 148 | - | sfondo(colors.magenta) |
| 148 | + | |
| 149 | - | term.setCursorPos(3, 6) |
| 149 | + | |
| 150 | - | term.write("Per favore, appoggia la tua impronta digitale")
|
| 150 | + | |
| 151 | - | term.setCursorPos(3, 7) |
| 151 | + | |
| 152 | - | term.write("nel sensore sulla destra del computer...")
|
| 152 | + | function concludi(conclusione) |
| 153 | sfondo(colors.lime) | |
| 154 | colore(colors.black) | |
| 155 | term.clear() | |
| 156 | term.setCursorPos(1, 1) | |
| 157 | titolo("OPERAZIONE CONCLUSA")
| |
| 158 | - | titolo("Richiedi una SIM Card", colors.purple, colors.white)
|
| 158 | + | |
| 159 | - | sfondo(colors.magenta) |
| 159 | + | sfondo(colors.lime) |
| 160 | - | term.setCursorPos(3, 4) |
| 160 | + | colore(colors.black) |
| 161 | - | term.write("Invio richiesta aut. da server g.c. in corso...")
|
| 161 | + | print(conclusione) |
| 162 | print("\n\n\nAttendere qualche secondo...")
| |
| 163 | end | |
| 164 | ||
| 165 | -- Variabili d'ambiente | |
| 166 | page = 0 | |
| 167 | player = nil | |
| 168 | ||
| 169 | - | term.setCursorPos(3, 6) |
| 169 | + | |
| 170 | - | term.write("Creazione della SIM...")
|
| 170 | + | |
| 171 | sfondo(colors.blue) | |
| 172 | colore(colors.white) | |
| 173 | clear() | |
| 174 | - | term.setCursorPos(3, 8) |
| 174 | + | |
| 175 | - | term.write("Conferma della registrazione...")
|
| 175 | + | titolo("POLIZIA DI FRONTIERA - POSTO DI NR PORTO", colors.orange, colors.white)
|
| 176 | sfondo(colors.blue) | |
| 177 | term.setCursorPos(1, 3) | |
| 178 | printCentered("Benvenuti a Zorya e nella Città di New Radeon.")
| |
| 179 | term.setCursorPos(1, 5) | |
| 180 | print("Per incominciare la procedura di verifica, fare clic destro sul blocco a destra del PC.\n")
| |
| 181 | print("Se si è già passati da questo Posto Frontiera e le credenziali sono valide, il cancello si aprirà.\n")
| |
| 182 | print("Se non si è mai passati da questo Posto Frontiera, si dovrà seguire la procedura di immigrazione.\n")
| |
| 183 | print("Per assistenza contattare il Ministero dell'INTERNO eseguendo il comando /discord")
| |
| 184 | - | term.setCursorPos(3, 10) |
| 184 | + | |
| 185 | - | term.write("SIM Registrata con successo!")
|
| 185 | + | titolo("POLIZIA DI FRONTIERA - IMMIGRAZIONE", colors.orange, colors.white)
|
| 186 | - | term.setCursorPos(3, 11) |
| 186 | + | sfondo(colors.blue) |
| 187 | - | term.write("La SIM Card verråA0 erogata a breve...")
|
| 187 | + | term.setCursorPos(1, 3) |
| 188 | print("Per concludere la procedura di immigrazione, leggere attentamente quanto segue.\n")
| |
| 189 | print("1) Si certifica che si ha letto e compreso nella loro interezza le Regole? /regole\n")
| |
| 190 | print("2) Si certifica che non si hanno reati pendenti al momento dell'immigrazione?\n")
| |
| 191 | - | os.reboot() |
| 191 | + | drawFilledBox(8, 16, 20, 18, colors.red) |
| 192 | drawFilledBox(31, 16, 43, 18, colors.lime) | |
| 193 | term.setCursorPos(36, 17) | |
| 194 | term.write("SI")
| |
| 195 | term.setCursorPos(13, 17) | |
| 196 | sfondo(colors.red) | |
| 197 | term.write("NO")
| |
| 198 | - | if page == 0 and ev == "mouse_click" and c >= 15 then |
| 198 | + | |
| 199 | - | page = 1 |
| 199 | + | |
| 200 | - | elseif page == 1 and ev == "player" then |
| 200 | + | |
| 201 | - | page = 2 |
| 201 | + | |
| 202 | - | player = a |
| 202 | + | titolo("POLIZIA DI FRONTIERA - STAMPA DOCUMENTI", colors.orange, colors.white)
|
| 203 | sfondo(colors.blue) | |
| 204 | term.setCursorPos(1, 3) | |
| 205 | print("Creazione della SIM Card personale in corso.\n")
| |
| 206 | print("ATTENZIONE: La SIM Card è già dotata di Piano Tariffario di base e credito telefonico di cittadinanza.\n")
| |
| 207 | print("Invio richiesta aut. da server g.c. in corso...")
| |
| 208 | local h = http.get("https://gsm.rgbcraft.com/?request=registerNewNumber&mnc=1&player="..player)
| |
| 209 | data = h.readAll() | |
| 210 | h.close() | |
| 211 | data = json.json.decode(data) | |
| 212 | number = data.response | |
| 213 | number = "0"..number | |
| 214 | ||
| 215 | print("Creazione della SIM...")
| |
| 216 | ||
| 217 | iccid = sim.registerSim(false, number, "Highland Mobile Prepaid") | |
| 218 | ||
| 219 | print("Conferma della registrazione...")
| |
| 220 | ||
| 221 | local h = http.get("https://gsm.rgbcraft.com/?request=registerICCID&iccid="..iccid.."&phone_number="..number)
| |
| 222 | data = h.readAll() | |
| 223 | h.close() | |
| 224 | ||
| 225 | data2 = json.json.decode(data) | |
| 226 | ||
| 227 | if data2.status == 200 then | |
| 228 | print("SIM Registrata con successo!")
| |
| 229 | print("La SIM Card verrà erogata a breve...")
| |
| 230 | print("Inserire la SIM Card nel telefono cellulare per utilizzarla.")
| |
| 231 | sleep(1) | |
| 232 | sim.ejectSim() | |
| 233 | sleep(3) | |
| 234 | concludi("CANCELLO APERTO - BUONA GIORNATA")
| |
| 235 | rs.setOutput("bottom", true)
| |
| 236 | sleep(10) | |
| 237 | rs.setOutput("bottom", false)
| |
| 238 | os.reboot() | |
| 239 | else | |
| 240 | errore("Errore gateway HighlandMobile")
| |
| 241 | end | |
| 242 | end | |
| 243 | ||
| 244 | local ev, a, b, c = os.pullEvent() | |
| 245 | if page == 0 and ev == "player" then | |
| 246 | if (checkCredentials(a) == false) then | |
| 247 | player = a | |
| 248 | page = 1 | |
| 249 | else | |
| 250 | concludi("CANCELLO APERTO - BUONA GIORNATA!")
| |
| 251 | rs.setOutput("bottom", true)
| |
| 252 | sleep(10) | |
| 253 | rs.setOutput("bottom", false)
| |
| 254 | os.reboot() | |
| 255 | end | |
| 256 | elseif page == 1 and ev == "mouse_click" then | |
| 257 | --drawFilledBox(8, 16, 20, 18, colors.red) | |
| 258 | if b >= 8 and b <= 20 and c >= 16 and c <= 18 then | |
| 259 | errore("Procedura di immigrazione fallita. Rifiuto del candidato.")
| |
| 260 | --drawFilledBox(31, 16, 43, 18, colors.lime) | |
| 261 | elseif b >= 31 and b <= 43 and c >= 16 and c <= 18 then | |
| 262 | sfondo(colors.blue) | |
| 263 | term.clear() | |
| 264 | titolo("POLIZIA DI FRONTIERA - IMMIGRAZIONE", colors.orange, colors.white)
| |
| 265 | sfondo(colors.blue) | |
| 266 | term.setCursorPos(1, 3) | |
| 267 | print("Attesa risposta server identità digitale...\n")
| |
| 268 | rest = http.get("http://172.16.20.220/luanet/servlets/activator/?nome=" .. player)
| |
| 269 | if rest == nil then | |
| 270 | errore("Server identità digitale irraggiungibili")
| |
| 271 | end | |
| 272 | restTable = textutils.unserialize(rest.readAll()) | |
| 273 | if type(restTable) ~= "table" then | |
| 274 | errore("Risposta errata server identità digitale")
| |
| 275 | end | |
| 276 | if restTable.stato == "EA" then | |
| 277 | errore("Errore server identità digitale: " .. restTable.errore)
| |
| 278 | end | |
| 279 | if restTable.stato == "OK" then | |
| 280 | addToCredentials(player) | |
| 281 | print("Risposta accettata.")
| |
| 282 | sleep(1) | |
| 283 | page = 2 | |
| 284 | else | |
| 285 | errore("Errore non specificato")
| |
| 286 | end | |
| 287 | end | |
| 288 | end | |
| 289 | end |