Guest User

startup

a guest
May 12th, 2026
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.06 KB | None | 0 0
  1. -- funzioni helper di base
  2. local maxw, maxh = term.getSize()
  3.  
  4. os.loadAPI("json")
  5.  
  6. pl = peripheral.wrap("right")
  7. sim = peripheral.wrap("left")
  8.  
  9. function tablelength(T)
  10.     local count = 0
  11.     for _ in pairs(T) do
  12.         count = count + 1
  13.     end
  14.     return count
  15. end
  16.  
  17. function clear()
  18.     term.clear()
  19.     term.setCursorPos(1, 1)
  20. end
  21.  
  22. function clearRed()
  23.     sfondo(colors.red)
  24.     term.clear()
  25.     term.setCursorPos(1, 1)
  26. end
  27.  
  28. function colore(sfumatura)
  29.     term.setTextColour(sfumatura)
  30. end
  31.  
  32. function sfondo(sfumaturaSfondo)
  33.     term.setBackgroundColour(sfumaturaSfondo)
  34. end
  35.  
  36. function fineColore()
  37.     term.setTextColour(colours.white)
  38. end
  39.  
  40. function fineSfondo()
  41.     term.setBackgroundColour(colours.black)
  42. end
  43.  
  44. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  45. local function drawPixelInternal(xPos, yPos)
  46.     term.setCursorPos(xPos, yPos)
  47.     term.write(" ")
  48. end
  49.  
  50. local tColourLookup = {}
  51. for n = 1, 16 do
  52.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  53. end
  54.  
  55. function drawFilledBox(startX, startY, endX, endY, nColour)
  56.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= "number" or type(endY) ~= "number" or
  57.         (nColour ~= nil and type(nColour) ~= "number") then
  58.         error("Expected startX, startY, endX, endY, colour", 2)
  59.     end
  60.  
  61.     startX = math.floor(startX)
  62.     startY = math.floor(startY)
  63.     endX = math.floor(endX)
  64.     endY = math.floor(endY)
  65.  
  66.     if nColour then
  67.         term.setBackgroundColor(nColour)
  68.     end
  69.     if startX == endX and startY == endY then
  70.         drawPixelInternal(startX, startY)
  71.         return
  72.     end
  73.  
  74.     local minX = math.min(startX, endX)
  75.     if minX == startX then
  76.         minY = startY
  77.         maxX = endX
  78.         maxY = endY
  79.     else
  80.         minY = endY
  81.         maxX = startX
  82.         maxY = startY
  83.     end
  84.  
  85.     for x = minX, maxX do
  86.         for y = minY, maxY do
  87.             drawPixelInternal(x, y)
  88.         end
  89.     end
  90. end
  91.  
  92. function titolo(testo, bk, cl)
  93.     drawFilledBox(1, 1, maxw, 1, bk)
  94.     term.setCursorPos((maxw - #testo) / 2, 1)
  95.     colore(cl)
  96.     term.write(testo)
  97. end
  98.  
  99. function errore(errore)
  100.     sfondo(colors.red)
  101.     colore(colors.white)
  102.     term.clear()
  103.     term.setCursorPos(1, 1)
  104.     titolo("Errore irreversibile")
  105.     term.setCursorPos(1, 3)
  106.     sfondo(colors.red)
  107.     colore(colors.white)
  108.     print(errore)
  109.     print("\n\n\nAttendere qualche secondo...")
  110.     os.sleep(5)
  111.     os.reboot()
  112. end
  113.  
  114. -- Variabili d'ambiente
  115. page = 0
  116. player = nil
  117.  
  118. -- Programma
  119. while true do
  120.     sfondo(colors.magenta)
  121.     colore(colors.white)
  122.     clear()
  123.     if page == 0 then
  124.         titolo("Highland Mobile", colors.purple, colors.white)
  125.         sfondo(colors.magenta)
  126.         term.setCursorPos(2, 3)
  127.         term.write("Ciao e benvenuto su RGBCraft!")
  128.         term.setCursorPos(2, 5)
  129.         term.write("Noi siamo la                  , operatore")
  130.         term.setCursorPos(2, 6)
  131.         term.write("statale di telefonia mobile.")
  132.         term.setCursorPos(2, 8)
  133.         term.write("Cliccando sul bottone sottotante potrai")
  134.         term.setCursorPos(2, 9)
  135.         term.write("richiedere la tua nuovissima SIM Card")
  136.         term.setCursorPos(2, 10)
  137.         term.write("con il nostro piano scelto apposta per te!")
  138.         term.setCursorPos(2, 12)
  139.         term.write("Piano personalizzato: Simple20")
  140.         drawFilledBox(8, 15, 42, 17, colors.purple)
  141.         term.setCursorPos(16, 16)
  142.         term.write("Avvia la procedura!")
  143.         sfondo(colors.purple)
  144.         term.setCursorPos(15, 5)
  145.         term.write("Highland MobileTM")
  146.     elseif page == 1 then
  147.         titolo("Richiedi una SIM Card", colors.purple, colors.white)
  148.         sfondo(colors.magenta)
  149.         term.setCursorPos(3, 6)
  150.         term.write("Per favore, appoggia la tua impronta digitale")
  151.         term.setCursorPos(3, 7)
  152.         term.write("nel sensore sulla destra del computer...")
  153.     elseif page == 2 then
  154.         if player == nil then
  155.             errore()
  156.         end
  157.  
  158.         titolo("Richiedi una SIM Card", colors.purple, colors.white)
  159.         sfondo(colors.magenta)
  160.         term.setCursorPos(3, 4)
  161.         term.write("Invio richiesta aut. da server g.c. in corso...")
  162.         local h = http.get("https://gsm.rgbcraft.com/?request=registerNewNumber&mnc=1&player="..player)
  163.         data = h.readAll()
  164.         h.close()
  165.         data = json.json.decode(data)
  166.         number = data.response
  167.         number = "0"..number
  168.  
  169.         term.setCursorPos(3, 6)
  170.         term.write("Creazione della SIM...")
  171.  
  172.         iccid = sim.registerSim(false, number, "Highland Mobile Prepaid")
  173.  
  174.         term.setCursorPos(3, 8)
  175.         term.write("Conferma della registrazione...")
  176.  
  177.         local h = http.get("https://gsm.rgbcraft.com/?request=registerICCID&iccid="..iccid.."&phone_number="..number)
  178.         data = h.readAll()
  179.         h.close()
  180.  
  181.         data2 = json.json.decode(data)
  182.  
  183.         if data2.status == 200 then
  184.             term.setCursorPos(3, 10)
  185.             term.write("SIM Registrata con successo!")
  186.             term.setCursorPos(3, 11)
  187.             term.write("La SIM Card verråA0 erogata a breve...")
  188.             sleep(1)
  189.             sim.ejectSim()
  190.             sleep(3)
  191.             os.reboot()
  192.         else
  193.             errore()
  194.         end
  195.     end
  196.    
  197.     local ev, a, b, c = os.pullEvent()
  198.     if page == 0 and ev == "mouse_click" and c >= 15 then
  199.         page = 1
  200.     elseif page == 1 and ev == "player" then
  201.         page = 2
  202.         player = a
  203.     end
  204. end
Advertisement
Add Comment
Please, Sign In to add comment