Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Ufficio Postale Laser by CFG
- local maxw, maxh = term.getSize()
- code = ""
- os.pullEvent = os.pullEventRaw
- rs.setOutput("top", true)
- -- 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 colore(nome) term.setTextColor(nome) end
- function sfondo(nome) term.setBackgroundColor(nome) end
- function fineColore() term.setTextColour(colours.white) end
- function fineSfondo() term.setBackgroundColour(colours.black) end
- function titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.gray)
- term.setCursorPos((maxw - #testo) / 2, 1)
- colore(colors.white)
- term.write(testo)
- term.setCursorPos(1, 2)
- sfondo(colors.white)
- end
- function clear()
- sfondo(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- 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)
- term.write(errore)
- print("\n\n\nAttendere qualche secondo...")
- os.sleep(6)
- os.reboot()
- end
- function code()
- filename = "officecode"
- if fs.exists(filename) then
- h = fs.open(filename, "r")
- text = h.readAll()
- h.close()
- code = text
- else
- errore("File 'OfficeCode' non esiste")
- end
- end
- function faq()
- clear()
- titolo("Laser HUB | F.A.Q")
- colore(colors.black)
- testo = "Work In progress"
- term.setCursorPos((maxw - #testo) / 2, 11)
- term.write(testo)
- drawFilledBox(43, 16, 48, 18, colors.red) -- FileBox (INFO)
- testo = "HOME"
- term.setCursorPos(44, 17)
- term.write(testo)
- os.startTimer(120)
- while true do
- local event, par1, par2, par3 = os.pullEventRaw()
- if par2 >= 43 and par2 <= 48 and par3 >= 16 and par3 <= 18 and event == "mouse_click" then -- Home
- os.reboot()
- end
- end
- end
- function cpComplete(player, nameNpay)
- a = http.get("http://172.16.20.227/~fabrimat/laser/shipmentcomplete.php?player="..player.."&office_code="..code.."&npay_user="..nameNpay)
- b = a.readAll()
- os.loadAPI("json")
- c = json.decode(b)
- if c["status"] == "success" then
- clear()
- titolo("Laser Office | Pagamento completato")
- colore(colors.red)
- testo = "Pagamento completato :)"
- term.setCursorPos((maxw - #testo) / 2, 9)
- term.write(testo)
- testo = "Grazie per aver usato Laser Logistics"
- term.setCursorPos((maxw - #testo) / 2, 11)
- term.write(testo)
- return c
- else
- errore(c["description"])
- end
- end
- function cpCheck(player)
- a = http.get("http://172.16.20.227//~fabrimat/laser/officecheck.php?player="..player.."&office_code="..code)
- b = a.readAll()
- os.loadAPI("json")
- c = json.decode(b)
- if c["status"] == "success" then
- return c
- else
- errore(c["description"])
- end
- end
- function cpConsegna(player, nameNpay)
- clear()
- sfondo(colors.blue)
- titolo("Laser Office | Consegna Pacco")
- colore(colors.black)
- term.setCursorPos(1,2)
- print("\nBene, hai un pacco da consegnare.")
- rs.setOutput("top", false)
- rs.setOutput("back", false)
- print("\nDeposita il pacco nello sportello di sotto")
- print("\n\n\Digita un tasto qualsiasi quando hai messo il pacco nello sportello")
- os.pullEvent("key")
- rs.setOutput("top", true)
- rs.setOutput("back", true)
- os.sleep(1)
- if rs.getInput("left") then
- rs.setOutput("top", false)
- colore(colors.red)
- print("\nInserito materiale non conforme\n\n Attendere...")
- os.sleep(5)
- rs.setOutput("top", true)
- cpComplete(player, nameNpay)
- else
- cpComplete(player, nameNpay)
- end
- end
- function cpShip()
- clear()
- titolo("Laser Office | Consegna Pacco")
- colore(colors.black)
- testo = "Inserisci la tua mano nel lettore a destra"
- term.setCursorPos((maxw - #testo) / 2, 10)
- term.write(testo)
- os.startTimer(120)
- local event, player = os.pullEvent()
- if event == "player" then
- check = cpCheck(player)
- if check["status"] == "success" then
- clear()
- titolo("Laser Office | Pagamento")
- colore(colors.black)
- term.setCursorPos(1,2)
- print("\nBene, il tuo pacco sta per essere consegnato.")
- print("\nOra per ricevere il pagamento inserisci il tuo nome utente nPay.")
- utenteAccettato = false
- while utenteAccettato == false do
- term.setCursorPos(1, 9)
- term.write("Nome utente: ")
- utente = read()
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
- tabcheckuser = textutils.unserialize(checkuser)
- if tabcheckuser.stato == "OK" then
- term.setCursorPos(13, 9)
- colore(colors.lime)
- term.write(utente)
- colore(colors.black)
- utenteAccettato = true
- cpConsegna(player, utente)
- else
- term.setCursorPos(13, 9)
- colore(colors.red)
- term.write("Utente errato!")
- sleep(2)
- term.setCursorPos(13, 9)
- colore(colors.black)
- term.write(" ")
- end
- end
- else
- errore(check["description"])
- end
- end
- end
- function update()
- if not fs.exists(".permaboot") then
- local file fs.open(".permaboot", "w")
- file.writeLine("Permaboooot")
- file.close()
- end
- shell.run("pastebin get rETd40N3 logo")
- shell.run("rm json")
- shell.run("rm star2")
- shell.run("pastebin get nxbCGJnY star2")
- shell.run("rm startup")
- shell.run("mv star2 startup")
- shell.run("pastebin get ADaQ4War json")
- end
- update()
- code()
- sfondo(colors.white)
- term.clear()
- if rs.getInput("left") then
- rs.setOutput("top", false)
- end
- titolo("LASER OFFICE")
- -- 51X 19Y
- colore(colors.black)
- m = paintutils.loadImage("logo")
- paintutils.drawImage(m, 9, 3)
- term.setCursorPos(14, 11)
- sfondo(colors.white)
- term.write("L O G I S T I C S")
- drawFilledBox(15, 15, 35, 17, colors.red) -- FileBox (Consegna Pacco)
- testo = "Consegna Pacco"
- term.setCursorPos((maxw - #testo) / 2, 16)
- term.write(testo)
- drawFilledBox(42, 16, 48, 18, colors.red) -- FileBox (FAQ)
- testo = "F.A.Q"
- term.setCursorPos(43, 17)
- term.write(testo)
- colore(colors.black)
- while true do
- colore(colors.black)
- local event, par1, par2, par3 = os.pullEventRaw()
- if par2 >= 15 and par2 <= 35 and par3 >= 15 and par3 <= 17 and event == "mouse_click" then -- New Return
- cpShip()
- os.sleep(3)
- os.reboot()
- elseif par2 >= 42 and par2 <= 49 and par3 >= 16 and par3 <= 18 and event == "mouse_click" then -- FAQ
- faq()
- os.reboot()
- end
- print("\n\n ".. event)
- end
- os.sleep(45)
- os.reboot()
Add Comment
Please, Sign In to add comment