Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- funzioni helper di base
- local maxw, maxh = term.getSize()
- pl = peripheral.wrap("right")
- sim = peripheral.wrap("left")
- if fs.exists("json") == false then
- shell.run("pastebin get RPUyCMjG json")
- end
- os.loadAPI("json")
- function checkCredentials(player)
- if fs.exists("credentials") then
- local credList = fs.open("credentials", "r")
- if type(credList) == "table" then
- result = string.find(credList.readAll(), player)
- credList.close()
- if result == nil then
- return false
- else
- return true
- end
- else
- return false
- end
- else
- return false
- end
- return false
- end
- function addToCredentials(player)
- local credList = fs.open("credentials", "a")
- credList.writeLine(player)
- credList.close()
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do
- count = count + 1
- end
- return count
- end
- 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, bk, cl)
- drawFilledBox(1, 1, maxw, 1, colors.orange)
- term.setCursorPos((maxw - #testo) / 2, 1)
- colore(colors.black)
- term.write(testo)
- colore(colors.white)
- end
- function printCentered(text)
- curX, curY = term.getCursorPos()
- term.setCursorPos((maxw - #text) / 2, curY)
- term.write(text)
- 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
- function concludi(conclusione)
- sfondo(colors.lime)
- colore(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- titolo("OPERAZIONE CONCLUSA")
- term.setCursorPos(1, 3)
- sfondo(colors.lime)
- colore(colors.black)
- print(conclusione)
- print("\n\n\nAttendere qualche secondo...")
- end
- -- Variabili d'ambiente
- page = 0
- player = nil
- -- Programma
- while true do
- sfondo(colors.blue)
- colore(colors.white)
- clear()
- if page == 0 then
- titolo("POLIZIA DI FRONTIERA - POSTO DI NR PORTO", colors.orange, colors.white)
- sfondo(colors.blue)
- term.setCursorPos(1, 3)
- printCentered("Benvenuti a Zorya e nella Città di New Radeon.")
- term.setCursorPos(1, 5)
- print("Per incominciare la procedura di verifica, fare clic destro sul blocco a destra del PC.\n")
- print("Se si è già passati da questo Posto Frontiera e le credenziali sono valide, il cancello si aprirà.\n")
- print("Se non si è mai passati da questo Posto Frontiera, si dovrà seguire la procedura di immigrazione.\n")
- print("Per assistenza contattare il Ministero dell'INTERNO eseguendo il comando /discord")
- elseif page == 1 then
- titolo("POLIZIA DI FRONTIERA - IMMIGRAZIONE", colors.orange, colors.white)
- sfondo(colors.blue)
- term.setCursorPos(1, 3)
- print("Per concludere la procedura di immigrazione, leggere attentamente quanto segue.\n")
- print("1) Si certifica che si ha letto e compreso nella loro interezza le Regole? /regole\n")
- print("2) Si certifica che non si hanno reati pendenti al momento dell'immigrazione?\n")
- drawFilledBox(8, 16, 20, 18, colors.red)
- drawFilledBox(31, 16, 43, 18, colors.lime)
- term.setCursorPos(36, 17)
- term.write("SI")
- term.setCursorPos(13, 17)
- sfondo(colors.red)
- term.write("NO")
- elseif page == 2 then
- if player == nil then
- errore()
- end
- titolo("POLIZIA DI FRONTIERA - STAMPA DOCUMENTI", colors.orange, colors.white)
- sfondo(colors.blue)
- term.setCursorPos(1, 3)
- print("Creazione della SIM Card personale in corso.\n")
- print("ATTENZIONE: La SIM Card è già dotata di Piano Tariffario di base e credito telefonico di cittadinanza.\n")
- print("Invio richiesta aut. da server g.c. in corso...")
- local h = http.get("https://gsm.rgbcraft.com/?request=registerNewNumber&mnc=1&player="..player)
- data = h.readAll()
- h.close()
- data = json.json.decode(data)
- number = data.response
- number = "0"..number
- print("Creazione della SIM...")
- iccid = sim.registerSim(false, number, "Highland Mobile Prepaid")
- print("Conferma della registrazione...")
- local h = http.get("https://gsm.rgbcraft.com/?request=registerICCID&iccid="..iccid.."&phone_number="..number)
- data = h.readAll()
- h.close()
- data2 = json.json.decode(data)
- if data2.status == 200 then
- print("SIM Registrata con successo!")
- print("La SIM Card verrà erogata a breve...")
- print("Inserire la SIM Card nel telefono cellulare per utilizzarla.")
- sleep(1)
- sim.ejectSim()
- sleep(3)
- concludi("CANCELLO APERTO - BUONA GIORNATA")
- rs.setOutput("bottom", true)
- sleep(10)
- rs.setOutput("bottom", false)
- os.reboot()
- else
- errore("Errore gateway HighlandMobile")
- end
- end
- local ev, a, b, c = os.pullEvent()
- if page == 0 and ev == "player" then
- if (checkCredentials(a) == false) then
- player = a
- page = 1
- else
- concludi("CANCELLO APERTO - BUONA GIORNATA!")
- rs.setOutput("bottom", true)
- sleep(10)
- rs.setOutput("bottom", false)
- os.reboot()
- end
- elseif page == 1 and ev == "mouse_click" then
- --drawFilledBox(8, 16, 20, 18, colors.red)
- if b >= 8 and b <= 20 and c >= 16 and c <= 18 then
- errore("Procedura di immigrazione fallita. Rifiuto del candidato.")
- --drawFilledBox(31, 16, 43, 18, colors.lime)
- elseif b >= 31 and b <= 43 and c >= 16 and c <= 18 then
- sfondo(colors.blue)
- term.clear()
- titolo("POLIZIA DI FRONTIERA - IMMIGRAZIONE", colors.orange, colors.white)
- sfondo(colors.blue)
- term.setCursorPos(1, 3)
- print("Attesa risposta server identità digitale...\n")
- rest = http.get("http://172.16.20.220/luanet/servlets/activator/?nome=" .. player)
- if rest == nil then
- errore("Server identità digitale irraggiungibili")
- end
- restTable = textutils.unserialize(rest.readAll())
- if type(restTable) ~= "table" then
- errore("Risposta errata server identità digitale")
- end
- if restTable.stato == "EA" then
- errore("Errore server identità digitale: " .. restTable.errore)
- end
- if restTable.stato == "OK" then
- addToCredentials(player)
- print("Risposta accettata.")
- sleep(1)
- page = 2
- else
- errore("Errore non specificato")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment