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")
- 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, bk)
- term.setCursorPos((maxw - #testo) / 2, 1)
- colore(cl)
- term.write(testo)
- 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
- -- Variabili d'ambiente
- page = 0
- player = nil
- -- Programma
- while true do
- sfondo(colors.magenta)
- colore(colors.white)
- clear()
- if page == 0 then
- titolo("Highland Mobile", colors.purple, colors.white)
- sfondo(colors.magenta)
- term.setCursorPos(2, 3)
- term.write("Ciao e benvenuto su RGBCraft!")
- term.setCursorPos(2, 5)
- term.write("Noi siamo la , operatore")
- term.setCursorPos(2, 6)
- term.write("statale di telefonia mobile.")
- term.setCursorPos(2, 8)
- term.write("Cliccando sul bottone sottotante potrai")
- term.setCursorPos(2, 9)
- term.write("richiedere la tua nuovissima SIM Card")
- term.setCursorPos(2, 10)
- term.write("con il nostro piano scelto apposta per te!")
- term.setCursorPos(2, 12)
- term.write("Piano personalizzato: Simple20")
- drawFilledBox(8, 15, 42, 17, colors.purple)
- term.setCursorPos(16, 16)
- term.write("Avvia la procedura!")
- sfondo(colors.purple)
- term.setCursorPos(15, 5)
- term.write("Highland MobileTM")
- elseif page == 1 then
- titolo("Richiedi una SIM Card", colors.purple, colors.white)
- sfondo(colors.magenta)
- term.setCursorPos(3, 6)
- term.write("Per favore, appoggia la tua impronta digitale")
- term.setCursorPos(3, 7)
- term.write("nel sensore sulla destra del computer...")
- elseif page == 2 then
- if player == nil then
- errore("Morte e distruzione pt.2")
- end
- titolo("Richiedi una SIM Card", colors.purple, colors.white)
- sfondo(colors.magenta)
- term.setCursorPos(3, 4)
- term.write("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.decode(data)
- if data == nil or data.status ~= 200 then
- errore("Errore durante la richiesta di registrazione del numero!")
- end
- number = data.response
- number = "0"..number
- term.setCursorPos(3, 6)
- term.write("Creazione della SIM...")
- iccid = sim.registerSim(false, number, "Highland Mobile Prepaid")
- term.setCursorPos(3, 8)
- term.write("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.decode(data)
- if data2 == nil then
- errore("Morte e distruzione!")
- end
- if data2.status == 200 then
- term.setCursorPos(3, 10)
- term.write("SIM Registrata con successo!")
- term.setCursorPos(3, 11)
- term.write("La SIM Card verrà erogata a breve...")
- sleep(1)
- sim.ejectSim()
- sleep(3)
- os.reboot()
- else
- errore("Errore nell'associazione dell'ICCID al numero di telefono!")
- end
- end
- local ev, a, b, c = os.pullEvent()
- if page == 0 and ev == "mouse_click" and c >= 15 then
- page = 1
- elseif page == 1 and ev == "player" then
- page = 2
- player = a
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment