SHOW:
|
|
- or go back to the newest paste.
| 1 | -- LaserHUB by CFG | |
| 2 | ||
| 3 | local maxw, maxh = term.getSize() | |
| 4 | local printer = peripheral.wrap("back")
| |
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
| 9 | local function drawPixelInternal(xPos, yPos) | |
| 10 | term.setCursorPos(xPos, yPos) | |
| 11 | term.write(" ")
| |
| 12 | end | |
| 13 | ||
| 14 | local tColourLookup = {}
| |
| 15 | for n = 1, 16 do | |
| 16 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 17 | end | |
| 18 | ||
| 19 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 20 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
| 21 | "number" or type(endY) ~= "number" or | |
| 22 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 23 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 24 | end | |
| 25 | ||
| 26 | startX = math.floor(startX) | |
| 27 | startY = math.floor(startY) | |
| 28 | endX = math.floor(endX) | |
| 29 | endY = math.floor(endY) | |
| 30 | ||
| 31 | if nColour then term.setBackgroundColor(nColour) end | |
| 32 | if startX == endX and startY == endY then | |
| 33 | drawPixelInternal(startX, startY) | |
| 34 | return | |
| 35 | end | |
| 36 | ||
| 37 | local minX = math.min(startX, endX) | |
| 38 | if minX == startX then | |
| 39 | minY = startY | |
| 40 | maxX = endX | |
| 41 | maxY = endY | |
| 42 | else | |
| 43 | minY = endY | |
| 44 | maxX = startX | |
| 45 | maxY = startY | |
| 46 | end | |
| 47 | ||
| 48 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
| 49 | end | |
| 50 | ||
| 51 | function colore(nome) term.setTextColor(nome) end | |
| 52 | ||
| 53 | function sfondo(nome) term.setBackgroundColor(nome) end | |
| 54 | ||
| 55 | function fineColore() term.setTextColour(colours.white) end | |
| 56 | ||
| 57 | function fineSfondo() term.setBackgroundColour(colours.black) end | |
| 58 | ||
| 59 | function titolo(testo) | |
| 60 | drawFilledBox(1, 1, maxw, 1, colors.gray) | |
| 61 | term.setCursorPos((maxw - #testo) / 2, 1) | |
| 62 | colore(colors.white) | |
| 63 | term.write(testo) | |
| 64 | term.setCursorPos(1, 2) | |
| 65 | sfondo(colors.white) | |
| 66 | end | |
| 67 | ||
| 68 | function clear() | |
| 69 | sfondo(colors.white) | |
| 70 | term.clear() | |
| 71 | term.setCursorPos(1, 1) | |
| 72 | end | |
| 73 | ||
| 74 | function errore(errore) | |
| 75 | sfondo(colors.red) | |
| 76 | colore(colors.white) | |
| 77 | term.clear() | |
| 78 | term.setCursorPos(1, 1) | |
| 79 | titolo("Errore irreversibile")
| |
| 80 | term.setCursorPos(1, 3) | |
| 81 | sfondo(colors.red) | |
| 82 | colore(colors.white) | |
| 83 | term.write(errore) | |
| 84 | print("\n\n\nAttendere qualche secondo...")
| |
| 85 | os.sleep(5) | |
| 86 | os.reboot() | |
| 87 | end | |
| 88 | ||
| 89 | function update() | |
| 90 | shell.run("pastebin get rETd40N3 logo")
| |
| 91 | shell.run("rm json")
| |
| 92 | shell.run("rm star2")
| |
| 93 | shell.run("pastebin get N6ckmYVe star2")
| |
| 94 | shell.run("rm startup")
| |
| 95 | shell.run("mv star2 startup")
| |
| 96 | shell.run("pastebin get ADaQ4War json")
| |
| 97 | end | |
| 98 | ||
| 99 | function newJobCheck(player) | |
| 100 | a = http.get("http://172.16.20.227//~fabrimat/laser/usercheck.php?player=".. player)
| |
| 101 | b = a.readAll() | |
| 102 | os.loadAPI("json")
| |
| 103 | c = json.decode(b) | |
| 104 | ||
| 105 | if c["status"] == "success" then | |
| 106 | return c | |
| 107 | else | |
| 108 | errore(c["description"]) | |
| 109 | end | |
| 110 | ||
| 111 | end | |
| 112 | ||
| 113 | function pagamenti() | |
| 114 | ||
| 115 | a = http.get("http://172.16.20.227/~fabrimat/laser/payments.php")
| |
| 116 | b = a.readAll() | |
| 117 | os.loadAPI("json")
| |
| 118 | c = json.decode(b) | |
| 119 | ||
| 120 | if c["status"] == "success" then | |
| 121 | return c | |
| 122 | else | |
| 123 | errore(c["description"]) | |
| 124 | end | |
| 125 | end | |
| 126 | ||
| 127 | function spedizione(player, tier) | |
| 128 | ||
| 129 | if printer.getPaperLevel() > 0 and printer.getInkLevel() > 0 then | |
| 130 | a = http.get("http://172.16.20.227/~fabrimat/laser/newshipment.php?player="..player.."&tier="..tier)
| |
| 131 | b = a.readAll() | |
| 132 | os.loadAPI("json")
| |
| 133 | c = json.decode(b) | |
| 134 | ||
| 135 | ||
| 136 | if c["status"] == "success" then | |
| 137 | if printer.newPage() then | |
| 138 | printer.write("Laser Logistics")
| |
| 139 | printer.setCursorPos(1, 2) | |
| 140 | printer.write("Nome corriere "..c["player"])
| |
| 141 | printer.setCursorPos(1, 4) | |
| 142 | printer.write("-----------")
| |
| 143 | printer.setCursorPos(1, 5) | |
| 144 | printer.write("Mittente:")
| |
| 145 | printer.setCursorPos(1, 6) | |
| 146 | printer.write(c["sender"]["name"]) | |
| 147 | printer.setCursorPos(1, 7) | |
| 148 | printer.write(c["sender"]["address"]) | |
| 149 | printer.setCursorPos(1, 9) | |
| 150 | printer.write("-----------")
| |
| 151 | printer.setCursorPos(1, 10) | |
| 152 | printer.write("Destinatario: ")
| |
| 153 | printer.setCursorPos(1, 11) | |
| 154 | printer.write(c["recipient"]["name"]) | |
| 155 | printer.setCursorPos(1, 12) | |
| 156 | printer.write("Ufficio postale di: ")
| |
| 157 | printer.setCursorPos(1, 13) | |
| 158 | printer.write(c["office"]["name"].." "..c["office"]["zip"]) | |
| 159 | printer.setCursorPos(1, 15) | |
| 160 | printer.write("Pagamento in contrassegno")
| |
| 161 | printer.setCursorPos(1, 16) | |
| 162 | printer.write("Valore: "..c["office"]["value"])
| |
| 163 | printer.setCursorPos(1, 18) | |
| 164 | printer.write("Da consegnare entro il: ")
| |
| 165 | printer.setCursorPos(1, 19) | |
| 166 | printer.write(c["due"]) | |
| 167 | ||
| 168 | printer.setPageTitle("Laser Logistic Spedizione")
| |
| 169 | printer.endPage() | |
| 170 | ||
| 171 | os.sleep(2) | |
| 172 | rs.setOutput("back", true)
| |
| 173 | os.sleep(0.1) | |
| 174 | rs.setOutput("back", false)
| |
| 175 | ||
| 176 | else | |
| 177 | errore("Stampante non funzionante :/")
| |
| 178 | end | |
| 179 | return c | |
| 180 | ||
| 181 | else | |
| 182 | errore(c["description"]) | |
| 183 | end | |
| 184 | else | |
| 185 | errore("Stampante non funzionante :/")
| |
| 186 | end | |
| 187 | ||
| 188 | end | |
| 189 | ||
| 190 | function newJob() | |
| 191 | clear() | |
| 192 | titolo("Laser HUB | Nuova spedizione")
| |
| 193 | ||
| 194 | pag = pagamenti() | |
| 195 | ||
| 196 | colore(colors.black) | |
| 197 | testo = "Tocca il lettore di fianco" | |
| 198 | term.setCursorPos((maxw - #testo) / 2, 10) | |
| 199 | term.write(testo) | |
| 200 | ||
| 201 | os.startTimer(120) | |
| 202 | local event, player = os.pullEvent() | |
| 203 | if event == "player" then | |
| 204 | check = newJobCheck(player) | |
| 205 | if check["status"] == "success" then | |
| 206 | clear() | |
| 207 | sfondo(colors.blue) | |
| 208 | titolo("Laser HUB | Nuova spedizione")
| |
| 209 | ||
| 210 | ||
| 211 | colore(colors.black) | |
| 212 | ||
| 213 | drawFilledBox(10, 6, 38, 8, colors.yellow) | |
| 214 | testo = "Consegna breve distanza" | |
| 215 | term.setCursorPos(11, 7) | |
| 216 | print(testo) | |
| 217 | term.setCursorPos(11, 8) | |
| 218 | print("Pagamento tra "..pag["tier_1"]["min"].." e "..pag["tier_1"]["max"].." IC")
| |
| 219 | ||
| 220 | drawFilledBox(10, 10, 38, 12, colors.yellow) | |
| 221 | testo = "Consegna media distanza" | |
| 222 | term.setCursorPos(11, 11) | |
| 223 | term.write(testo) | |
| 224 | term.setCursorPos(11, 12) | |
| 225 | print("Pagamento tra "..pag["tier_2"]["min"].." e "..pag["tier_2"]["max"].." IC")
| |
| 226 | ||
| 227 | drawFilledBox(10, 14, 38, 16, colors.yellow) | |
| 228 | testo = "Consegna lunga distanza" | |
| 229 | term.setCursorPos(11, 15) | |
| 230 | term.write(testo) | |
| 231 | term.setCursorPos(11, 16) | |
| 232 | print("Pagamento tra "..pag["tier_3"]["min"].." e "..pag["tier_3"]["max"].." IC")
| |
| 233 | ||
| 234 | os.startTimer(120) | |
| 235 | while true do | |
| 236 | local event, par1, par2, par3 = os.pullEvent("mouse_click")
| |
| 237 | if par2 >= 11 and par2 <= 38 and par3 >= 6 and par3 <= 8 then -- Zona 1 | |
| 238 | ||
| 239 | clear() | |
| 240 | titolo("Laser HUB | Nuovo Lavoro breve distanza")
| |
| 241 | colore(colors.black) | |
| 242 | term.setCursorPos(1, 5) | |
| 243 | print("Stampa in corso...")
| |
| 244 | c = spedizione(player, "1") | |
| 245 | break | |
| 246 | elseif par2 >= 11 and par2 <= 38 and par3 >= 10 and par3 <= 12 then -- Zona 2 | |
| 247 | clear() | |
| 248 | titolo("Laser HUB | Nuovo Lavoro media distanza")
| |
| 249 | colore(colors.black) | |
| 250 | term.setCursorPos(1, 5) | |
| 251 | print("Stampa in corso...")
| |
| 252 | c = spedizione(player, "2") | |
| 253 | break | |
| 254 | elseif par2 >= 11 and par2 <= 38 and par3 >= 14 and par3 <= 16 then -- Zona 3 | |
| 255 | clear() | |
| 256 | titolo("Laser HUB | Nuovo Lavoro lunga distanza")
| |
| 257 | colore(colors.black) | |
| 258 | term.setCursorPos(1, 5) | |
| 259 | print("Stampa in corso...")
| |
| 260 | c = spedizione(player, "3") | |
| 261 | break | |
| 262 | ||
| 263 | end | |
| 264 | end | |
| 265 | ||
| 266 | ||
| 267 | ||
| 268 | else | |
| 269 | errore(check["description"]) | |
| 270 | end | |
| 271 | end | |
| 272 | ||
| 273 | ||
| 274 | ||
| 275 | end | |
| 276 | ||
| 277 | function faq() | |
| 278 | clear() | |
| 279 | titolo("Laser HUB | F.A.Q")
| |
| 280 | colore(colors.black) | |
| 281 | testo = "Work In progress" | |
| 282 | term.setCursorPos((maxw - #testo) / 2, 11) | |
| 283 | term.write(testo) | |
| 284 | ||
| 285 | ||
| 286 | drawFilledBox(43, 16, 48, 18, colors.red) -- FileBox (INFO) | |
| 287 | ||
| 288 | testo = "HOME" | |
| 289 | term.setCursorPos(44, 17) | |
| 290 | term.write(testo) | |
| 291 | ||
| 292 | os.startTimer(120) | |
| 293 | while true do | |
| 294 | local event, par1, par2, par3 = os.pullEvent("mouse_click")
| |
| 295 | if par2 >= 43 and par2 <= 48 and par3 >= 16 and par3 <= 18 then -- Home | |
| 296 | os.reboot() | |
| 297 | end | |
| 298 | end | |
| 299 | ||
| 300 | end | |
| 301 | ||
| 302 | update() | |
| 303 | sfondo(colors.white) | |
| 304 | term.clear() | |
| 305 | ||
| 306 | titolo("LASER HUB")
| |
| 307 | ||
| 308 | -- 51X 19Y | |
| 309 | colore(colors.black) | |
| 310 | m = paintutils.loadImage("logo")
| |
| 311 | paintutils.drawImage(m, 9, 3) | |
| 312 | term.setCursorPos(14, 11) | |
| 313 | sfondo(colors.white) | |
| 314 | term.write("L O G I S T I C S")
| |
| 315 | ||
| 316 | ||
| 317 | ||
| 318 | ||
| 319 | drawFilledBox(15, 15, 35, 17, colors.red) -- FileBox (Nuovo Lavoro) | |
| 320 | ||
| 321 | testo = "Nuovo Lavoro" | |
| 322 | term.setCursorPos((maxw - #testo) / 2, 16) | |
| 323 | term.write(testo) | |
| 324 | ||
| 325 | drawFilledBox(42, 16, 48, 18, colors.red) -- FileBox (INFO) | |
| 326 | ||
| 327 | testo = "F.A.Q" | |
| 328 | term.setCursorPos(43, 17) | |
| 329 | term.write(testo) | |
| 330 | ||
| 331 | while true do | |
| 332 | local event, par1, par2, par3 = os.pullEvent("mouse_click")
| |
| 333 | if par2 >= 15 and par2 <= 35 and par3 >= 15 and par3 <= 17 then -- New Job | |
| 334 | newJob() | |
| 335 | ||
| 336 | sleep(3) | |
| 337 | os.reboot() | |
| 338 | ||
| 339 | elseif par2 >= 42 and par2 <= 49 and par3 >= 16 and par3 <= 18 then -- FAQ | |
| 340 | faq() | |
| 341 | ||
| 342 | end | |
| 343 | end |