lego11

PNRF

May 5th, 2026
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.98 KB | None | 0 0
  1. -- CFG Program Files
  2.  
  3. local maxw, maxh = term.getSize()
  4. local printer = peripheral.wrap("back")
  5.  
  6. os.pullEvent = os.pullEventRaw
  7.  
  8. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  9. local function drawPixelInternal(xPos, yPos)
  10.     term.setCursorPos(xPos, yPos)
  11.     term.write(" ")
  12. end
  13.  
  14. Gplayer = ""
  15.  
  16. local tColourLookup = {}
  17. for n = 1, 16 do
  18.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  19. end
  20.  
  21. function drawFilledBox(startX, startY, endX, endY, nColour)
  22.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  23.         "number" or type(endY) ~= "number" or
  24.         (nColour ~= nil and type(nColour) ~= "number") then
  25.         error("Expected startX, startY, endX, endY, colour", 2)
  26.     end
  27.  
  28.     startX = math.floor(startX)
  29.     startY = math.floor(startY)
  30.     endX = math.floor(endX)
  31.     endY = math.floor(endY)
  32.  
  33.     if nColour then term.setBackgroundColor(nColour) end
  34.     if startX == endX and startY == endY then
  35.         drawPixelInternal(startX, startY)
  36.         return
  37.     end
  38.  
  39.     local minX = math.min(startX, endX)
  40.     if minX == startX then
  41.         minY = startY
  42.         maxX = endX
  43.         maxY = endY
  44.     else
  45.         minY = endY
  46.         maxX = startX
  47.         maxY = startY
  48.     end
  49.  
  50.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  51. end
  52.  
  53. function colore(nome) term.setTextColor(nome) end
  54.  
  55. function sfondo(nome) term.setBackgroundColor(nome) end
  56.  
  57. function fineColore() term.setTextColour(colours.white) end
  58.  
  59. function fineSfondo() term.setBackgroundColour(colours.black) end
  60.  
  61. function titolo(testo)
  62.     drawFilledBox(1, 1, maxw, 1, colors.gray)
  63.     term.setCursorPos((maxw - #testo) / 2, 1)
  64.     colore(colors.white)
  65.     term.write(testo)
  66.     term.setCursorPos(1, 2)
  67.     sfondo(colors.white)
  68. end
  69.  
  70. function clear()
  71.     sfondo(colors.white)
  72.     term.clear()
  73.     term.setCursorPos(1, 1)
  74. end
  75.  
  76. function errore(errore)
  77.     sfondo(colors.red)
  78.     colore(colors.white)
  79.     term.clear()
  80.     term.setCursorPos(1, 1)
  81.     titolo("Errore irreversibile")
  82.     term.setCursorPos(1, 3)
  83.     sfondo(colors.red)
  84.     colore(colors.white)
  85.     term.write(errore)
  86.     print("\n\n\nAttendere qualche secondo...")
  87.     os.sleep(6)
  88.     os.reboot()
  89. end
  90.  
  91. function print(message)
  92.  
  93.     if printer.getPaperLevel() == 0 then -- If there is no paper in the printer
  94.       errore("La carta nella stampante è finita!")
  95.     end
  96.    
  97.     if printer.getInkLevel() == 0 then -- If there is no ink in the printer
  98.       error("L'inchiostro nella stampante è finita!")
  99.     end
  100.    
  101.     -- There is paper and ink in the printer, we can now print a page
  102.    
  103.     if printer.newPage() then
  104.       printer.write("Frequenza:")
  105.      
  106.       printer.setCursorPos(1, 3)
  107.       printer.write("* "..message)
  108.      
  109.       printer.setCursorPos(1, 4)
  110.       printer.write("* Per maggiore info contatatta lego11")
  111.      
  112.       printer.setPageTitle("PNRF - Ricevuta")
  113.       printer.endPage()
  114.     else
  115.       errore("Stampante inceppata!")
  116.     end
  117. end
  118.  
  119. function make_payment(player, amount)
  120.     clear()
  121.     titolo("PNFR HUB | Pagamento")
  122.     colore(colors.black)
  123.     term.setCursorPos(1,3)
  124.     print("Inserisce le credenziali nPay\nper comprare il pagamento\nPrezzo da pagare: "..amount.." IC")
  125.  
  126.     term.setCursorPos(1,7)
  127.     term.write("Nome utente:")
  128.     term.setCursorPos(1,9)
  129.     term.write("Password:")
  130.  
  131.     term.setCursorPos(14,7)
  132.     username = read()
  133.  
  134.     term.setCursorPos(11,9)
  135.     password = read("*")
  136.  
  137.     a = http.get("https://pnrf.rgbcraft.com/api/do/payments?player="..player.."&username="..username.."&password="..password.."&amount="..amount)
  138.     if a ~= nil and a ~= "" then
  139.         b = a.readAll()
  140.         c = textutils.unserialize(b)
  141.         a.close()
  142.  
  143.         if c['status'] == "OK" then
  144.             clear()
  145.             titolo("PNFR HUB | Pagamento completato")
  146.             sfondo(colors.white)
  147.             colore(colors.black)
  148.             testo = "Frequenza assegnata: "..c['frequency']
  149.             term.setCursorPos((maxw - #testo) / 2, 11)
  150.             term.write(testo)
  151.             print("\n   Stiamo stampando la ricevuta..")
  152.             os.sleep(1)
  153.             print(c['frequency'])
  154.             os.sleep(8)
  155.             os.reboot()
  156.         else
  157.             errore(c['detail'])
  158.         end
  159.     else
  160.         errore("Server offline")
  161.     end
  162.    
  163.     os.sleep(5)
  164.  
  165.  
  166. end
  167.  
  168. function new_frequency(player)
  169.     a = http.get("https://pnrf.rgbcraft.com/api/check/newfrequency?player="..player)
  170.     if a ~= nil and a ~= "" then
  171.         b = a.readAll()
  172.         c = textutils.unserialize(b)
  173.         a.close()
  174.  
  175.         if c['status'] == "OK" then
  176.             clear()
  177.             titolo("PNFR HUB | Nuova Frequenza")
  178.             colore(colors.black)
  179.             testo = "Clicca qualsiasi tasto per confermare"
  180.             testo2 = "dovrai pagare: "..c['price']
  181.             testo3 = "Al momento hai ".. c['frequency'].." frequenza/e"
  182.             term.setCursorPos((maxw - #testo) / 2, 10)
  183.             term.write(testo)
  184.             term.setCursorPos((maxw - #testo2) / 2, 11)
  185.             term.write(testo2)
  186.             term.setCursorPos((maxw - #testo3) / 2, 13)
  187.             term.write(testo3)
  188.             os.pullEvent("key")
  189.  
  190.             make_payment(player, c['price'])
  191.  
  192.         elseif c['status'] == "TMF" then
  193.             clear()
  194.             titolo("PNFR HUB | Nuova Frequenza")
  195.             colore(colors.black)
  196.             testo = "Hai troppe frequenze!!, contatatta legoz"
  197.             term.setCursorPos((maxw - #testo) / 2, 11)
  198.             term.write(testo)
  199.             os.sleep(5)
  200.             os.reboot()
  201.         else
  202.             os.reboot()
  203.         end
  204.     else
  205.         errore("Server offline")
  206.     end
  207. end
  208.  
  209. function playerCheck(player)
  210.     a = http.get("https://pnrf.rgbcraft.com/api/checkplayer?player="..player)
  211.     if a ~= nil and a ~= "" then
  212.         b = a.readAll()
  213.         c = textutils.unserialize(b)
  214.         a.close()
  215.  
  216.         Gplayer = player
  217.         if c['status'] == "OK" then
  218.             clear()
  219.             titolo("PNFR HUB | Nuova Frequenza")
  220.             colore(colors.black)
  221.             testo = "Sei un nuovo utente!"
  222.             term.setCursorPos((maxw - #testo) / 2, 11)
  223.             term.write(testo)
  224.             os.sleep(1)
  225.             new_frequency(player)
  226.         elseif c['status'] == "NP" then
  227.             clear()
  228.             titolo("PNFR HUB | Nuova Frequenza")
  229.             colore(colors.black)
  230.             testo = "Utente già registrato.. ASPETTA!"
  231.             term.setCursorPos((maxw - #testo) / 2, 11)
  232.             term.write(testo)
  233.             os.sleep(1)
  234.             new_frequency(player)
  235.         else
  236.             os.reboot()
  237.         end
  238.     else
  239.         errore("Server offline")
  240.     end
  241. end
  242.  
  243. function new_Frequence()
  244.     clear()
  245.     titolo("PNFR HUB | Nuova Frequenza")
  246.     colore(colors.black)
  247.     testo = "Clicca il sensore posto al lato/sotto"
  248.     term.setCursorPos((maxw - #testo) / 2, 11)
  249.     term.write(testo)
  250.  
  251.     os.startTimer(120)
  252.     local event, player = os.pullEvent()
  253.     if event == "player" then
  254.         playerCheck(player)
  255.     end
  256. end
  257.  
  258. function faq()
  259.     clear()
  260.     titolo("PNFR HUB | F.A.Q")
  261.     colore(colors.black)
  262.     testo = "Work In progress"
  263.     term.setCursorPos((maxw - #testo) / 2, 11)
  264.     term.write(testo)
  265.  
  266.  
  267.     drawFilledBox(43, 16, 48, 18, colors.red) -- FileBox (INFO)
  268.  
  269.     testo = "HOME"
  270.     term.setCursorPos(44, 17)
  271.     term.write(testo)
  272.  
  273.     os.startTimer(120)
  274.     while true do
  275.         local event, par1, par2, par3 = os.pullEventRaw()
  276.         if par2 >= 43 and par2 <= 48 and par3 >= 16 and par3 <= 18 and event == "mouse_click" then -- Home
  277.             os.reboot()
  278.         end
  279.     end
  280.  
  281. end
  282.  
  283.  
  284. function update()
  285.     if not fs.exists(".permaboot") then
  286.         local file fs.open(".permaboot", "w")
  287.         file.writeLine("Permaboooot")
  288.         file.close()
  289.         os.reboot()
  290.     end    
  291.     shell.run("rm startup")
  292.     shell.run("pastebin get sg8epUiQ star")
  293.     shell.run("star")
  294.     shell.run("mv star startup")
  295.  
  296. end
  297.  
  298. update()
  299.  
  300.  
  301. sfondo(colors.white)
  302. term.clear()
  303.  
  304.  
  305.  
  306. titolo("PNRF HUB")
  307.  
  308. -- 51X 19Y
  309. colore(colors.black)
  310. sfondo(colors.white)
  311.  
  312.  
  313. drawFilledBox(15, 11, 35, 13, colors.red) -- FileBox (Consegna Pacco)
  314.  
  315. testo = "Nuova Frequenza"
  316. term.setCursorPos((maxw - #testo) / 2, 12)
  317. term.write(testo)
  318.  
  319. --drawFilledBox(42, 16, 48, 18, colors.red) -- FileBox (FAQ)
  320.  
  321. --testo = "F.A.Q"
  322. --term.setCursorPos(43, 17)
  323. --term.write(testo)
  324.  
  325. colore(colors.black)
  326.  
  327. while true do
  328.     colore(colors.black)
  329.     local event, par1, par2, par3 = os.pullEventRaw()
  330.     if par2 >= 15 and par2 <= 35 and par3 >= 11 and par3 <= 13 and event == "mouse_click" then -- New Return
  331.         new_Frequence()
  332.         os.sleep(3)
  333.         os.reboot()
  334.     --[[
  335.     elseif par2 >= 42 and par2 <= 49 and par3 >= 16 and par3 <= 18 and event == "mouse_click"  then -- FAQ
  336.         faq()
  337.         os.reboot()
  338.     --]]    
  339.     end
  340. end
  341.  
  342. os.sleep(45)
  343.  
Advertisement
Add Comment
Please, Sign In to add comment