Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- LaserHUB by CFG
- local maxw, maxh = term.getSize()
- local printer = peripheral.wrap("back")
- -- 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(5)
- os.reboot()
- end
- function update()
- shell.run("pastebin get rETd40N3 logo")
- shell.run("rm json")
- shell.run("rm star2")
- shell.run("pastebin get N6ckmYVe star2")
- shell.run("rm startup")
- shell.run("mv star2 startup")
- shell.run("pastebin get ADaQ4War json")
- end
- function newJobCheck(player)
- a = http.get("http://172.16.20.227//~fabrimat/laser/usercheck.php?player=".. player)
- b = a.readAll()
- os.loadAPI("json")
- c = json.decode(b)
- if c["status"] == "success" then
- return c
- else
- errore(c["description"])
- end
- end
- function pagamenti()
- a = http.get("http://172.16.20.227/~fabrimat/laser/payments.php")
- b = a.readAll()
- os.loadAPI("json")
- c = json.decode(b)
- if c["status"] == "success" then
- return c
- else
- errore(c["description"])
- end
- end
- function spedizione(player, tier)
- if printer.getPaperLevel() > 0 and printer.getInkLevel() > 0 then
- a = http.get("http://172.16.20.227/~fabrimat/laser/newshipment.php?player="..player.."&tier="..tier)
- b = a.readAll()
- os.loadAPI("json")
- c = json.decode(b)
- if c["status"] == "success" then
- if printer.newPage() then
- printer.write("Laser Logistics")
- printer.setCursorPos(1, 2)
- printer.write("Nome corriere "..c["player"])
- printer.setCursorPos(1, 4)
- printer.write("-----------")
- printer.setCursorPos(1, 5)
- printer.write("Mittente:")
- printer.setCursorPos(1, 6)
- printer.write(c["sender"]["name"])
- printer.setCursorPos(1, 7)
- printer.write(c["sender"]["address"])
- printer.setCursorPos(1, 9)
- printer.write("-----------")
- printer.setCursorPos(1, 10)
- printer.write("Destinatario: ")
- printer.setCursorPos(1, 11)
- printer.write(c["recipient"]["name"])
- printer.setCursorPos(1, 12)
- printer.write("Ufficio postale di: ")
- printer.setCursorPos(1, 13)
- printer.write(c["office"]["name"].." "..c["office"]["zip"])
- printer.setCursorPos(1, 15)
- printer.write("Pagamento in contrassegno")
- printer.setCursorPos(1, 16)
- printer.write("Valore: "..c["office"]["value"])
- printer.setCursorPos(1, 18)
- printer.write("Da consegnare entro il: ")
- printer.setCursorPos(1, 19)
- printer.write(c["due"])
- printer.setPageTitle("Laser Logistic Spedizione")
- printer.endPage()
- os.sleep(2)
- rs.setOutput("back", true)
- os.sleep(0.1)
- rs.setOutput("back", false)
- else
- errore("Stampante non funzionante :/")
- end
- return c
- else
- errore(c["description"])
- end
- else
- errore("Stampante non funzionante :/")
- end
- end
- function newJob()
- clear()
- titolo("Laser HUB | Nuova spedizione")
- pag = pagamenti()
- colore(colors.black)
- testo = "Tocca il lettore di fianco"
- term.setCursorPos((maxw - #testo) / 2, 10)
- term.write(testo)
- os.startTimer(120)
- local event, player = os.pullEvent()
- if event == "player" then
- check = newJobCheck(player)
- if check["status"] == "success" then
- clear()
- sfondo(colors.blue)
- titolo("Laser HUB | Nuova spedizione")
- colore(colors.black)
- drawFilledBox(10, 6, 38, 8, colors.yellow)
- testo = "Consegna breve distanza"
- term.setCursorPos(11, 7)
- print(testo)
- term.setCursorPos(11, 8)
- print("Pagamento tra "..pag["tier_1"]["min"].." e "..pag["tier_1"]["max"].." IC")
- drawFilledBox(10, 10, 38, 12, colors.yellow)
- testo = "Consegna media distanza"
- term.setCursorPos(11, 11)
- term.write(testo)
- term.setCursorPos(11, 12)
- print("Pagamento tra "..pag["tier_2"]["min"].." e "..pag["tier_2"]["max"].." IC")
- drawFilledBox(10, 14, 38, 16, colors.yellow)
- testo = "Consegna lunga distanza"
- term.setCursorPos(11, 15)
- term.write(testo)
- term.setCursorPos(11, 16)
- print("Pagamento tra "..pag["tier_3"]["min"].." e "..pag["tier_3"]["max"].." IC")
- os.startTimer(120)
- while true do
- local event, par1, par2, par3 = os.pullEvent("mouse_click")
- if par2 >= 11 and par2 <= 38 and par3 >= 6 and par3 <= 8 then -- Zona 1
- clear()
- titolo("Laser HUB | Nuovo Lavoro breve distanza")
- colore(colors.black)
- term.setCursorPos(1, 5)
- print("Stampa in corso...")
- c = spedizione(player, "1")
- break
- elseif par2 >= 11 and par2 <= 38 and par3 >= 10 and par3 <= 12 then -- Zona 2
- clear()
- titolo("Laser HUB | Nuovo Lavoro media distanza")
- colore(colors.black)
- term.setCursorPos(1, 5)
- print("Stampa in corso...")
- c = spedizione(player, "2")
- break
- elseif par2 >= 11 and par2 <= 38 and par3 >= 14 and par3 <= 16 then -- Zona 3
- clear()
- titolo("Laser HUB | Nuovo Lavoro lunga distanza")
- colore(colors.black)
- term.setCursorPos(1, 5)
- print("Stampa in corso...")
- c = spedizione(player, "3")
- break
- end
- end
- else
- errore(check["description"])
- end
- 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.pullEvent("mouse_click")
- if par2 >= 43 and par2 <= 48 and par3 >= 16 and par3 <= 18 then -- Home
- os.reboot()
- end
- end
- end
- update()
- sfondo(colors.white)
- term.clear()
- titolo("LASER HUB")
- -- 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 (Nuovo Lavoro)
- testo = "Nuovo Lavoro"
- term.setCursorPos((maxw - #testo) / 2, 16)
- term.write(testo)
- drawFilledBox(42, 16, 48, 18, colors.red) -- FileBox (INFO)
- testo = "F.A.Q"
- term.setCursorPos(43, 17)
- term.write(testo)
- while true do
- local event, par1, par2, par3 = os.pullEvent("mouse_click")
- if par2 >= 15 and par2 <= 35 and par3 >= 15 and par3 <= 17 then -- New Job
- newJob()
- sleep(3)
- os.reboot()
- elseif par2 >= 42 and par2 <= 49 and par3 >= 16 and par3 <= 18 then -- FAQ
- faq()
- end
- end
Add Comment
Please, Sign In to add comment