SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Ufficio Postale Laser by CFG | |
| 2 | ||
| 3 | local maxw, maxh = term.getSize() | |
| 4 | ||
| 5 | code = "" | |
| 6 | ||
| 7 | os.pullEvent = os.pullEventRaw | |
| 8 | ||
| 9 | rs.setOutput("top", true)
| |
| 10 | ||
| 11 | ||
| 12 | -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
| 13 | local function drawPixelInternal(xPos, yPos) | |
| 14 | term.setCursorPos(xPos, yPos) | |
| 15 | term.write(" ")
| |
| 16 | end | |
| 17 | ||
| 18 | local tColourLookup = {}
| |
| 19 | for n = 1, 16 do | |
| 20 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
| |
| 21 | end | |
| 22 | ||
| 23 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 24 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
| 25 | "number" or type(endY) ~= "number" or | |
| 26 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 27 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 28 | end | |
| 29 | ||
| 30 | startX = math.floor(startX) | |
| 31 | startY = math.floor(startY) | |
| 32 | endX = math.floor(endX) | |
| 33 | endY = math.floor(endY) | |
| 34 | ||
| 35 | if nColour then term.setBackgroundColor(nColour) end | |
| 36 | if startX == endX and startY == endY then | |
| 37 | drawPixelInternal(startX, startY) | |
| 38 | return | |
| 39 | end | |
| 40 | ||
| 41 | local minX = math.min(startX, endX) | |
| 42 | if minX == startX then | |
| 43 | minY = startY | |
| 44 | maxX = endX | |
| 45 | maxY = endY | |
| 46 | else | |
| 47 | minY = endY | |
| 48 | maxX = startX | |
| 49 | maxY = startY | |
| 50 | end | |
| 51 | ||
| 52 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
| 53 | end | |
| 54 | ||
| 55 | function colore(nome) term.setTextColor(nome) end | |
| 56 | ||
| 57 | function sfondo(nome) term.setBackgroundColor(nome) end | |
| 58 | ||
| 59 | function fineColore() term.setTextColour(colours.white) end | |
| 60 | ||
| 61 | function fineSfondo() term.setBackgroundColour(colours.black) end | |
| 62 | ||
| 63 | function titolo(testo) | |
| 64 | drawFilledBox(1, 1, maxw, 1, colors.gray) | |
| 65 | term.setCursorPos((maxw - #testo) / 2, 1) | |
| 66 | colore(colors.white) | |
| 67 | term.write(testo) | |
| 68 | term.setCursorPos(1, 2) | |
| 69 | sfondo(colors.white) | |
| 70 | end | |
| 71 | ||
| 72 | function clear() | |
| 73 | sfondo(colors.white) | |
| 74 | term.clear() | |
| 75 | term.setCursorPos(1, 1) | |
| 76 | end | |
| 77 | ||
| 78 | function errore(errore) | |
| 79 | sfondo(colors.red) | |
| 80 | colore(colors.white) | |
| 81 | term.clear() | |
| 82 | term.setCursorPos(1, 1) | |
| 83 | titolo("Errore irreversibile")
| |
| 84 | term.setCursorPos(1, 3) | |
| 85 | sfondo(colors.red) | |
| 86 | colore(colors.white) | |
| 87 | term.write(errore) | |
| 88 | print("\n\n\nAttendere qualche secondo...")
| |
| 89 | os.sleep(6) | |
| 90 | os.reboot() | |
| 91 | end | |
| 92 | ||
| 93 | function code() | |
| 94 | filename = "officecode" | |
| 95 | if fs.exists(filename) then | |
| 96 | h = fs.open(filename, "r") | |
| 97 | text = h.readAll() | |
| 98 | h.close() | |
| 99 | code = text | |
| 100 | else | |
| 101 | errore("File 'OfficeCode' non esiste")
| |
| 102 | end | |
| 103 | ||
| 104 | end | |
| 105 | ||
| 106 | function faq() | |
| 107 | clear() | |
| 108 | titolo("Laser HUB | F.A.Q")
| |
| 109 | colore(colors.black) | |
| 110 | testo = "Work In progress" | |
| 111 | term.setCursorPos((maxw - #testo) / 2, 11) | |
| 112 | term.write(testo) | |
| 113 | ||
| 114 | ||
| 115 | drawFilledBox(43, 16, 48, 18, colors.red) -- FileBox (INFO) | |
| 116 | ||
| 117 | testo = "HOME" | |
| 118 | term.setCursorPos(44, 17) | |
| 119 | term.write(testo) | |
| 120 | ||
| 121 | os.startTimer(120) | |
| 122 | while true do | |
| 123 | local event, par1, par2, par3 = os.pullEventRaw() | |
| 124 | if par2 >= 43 and par2 <= 48 and par3 >= 16 and par3 <= 18 and event == "mouse_click" then -- Home | |
| 125 | os.reboot() | |
| 126 | end | |
| 127 | end | |
| 128 | ||
| 129 | end | |
| 130 | ||
| 131 | function cpComplete(player, nameNpay) | |
| 132 | ||
| 133 | a = http.get("http://172.16.20.227/~fabrimat/laser/shipmentcomplete.php?player="..player.."&office_code="..code.."&npay_user="..nameNpay)
| |
| 134 | b = a.readAll() | |
| 135 | os.loadAPI("json")
| |
| 136 | c = json.decode(b) | |
| 137 | ||
| 138 | if c["status"] == "success" then | |
| 139 | clear() | |
| 140 | titolo("Laser Office | Pagamento completato")
| |
| 141 | ||
| 142 | colore(colors.red) | |
| 143 | testo = "Pagamento completato :)" | |
| 144 | term.setCursorPos((maxw - #testo) / 2, 9) | |
| 145 | term.write(testo) | |
| 146 | ||
| 147 | testo = "Grazie per aver usato Laser Logistics" | |
| 148 | term.setCursorPos((maxw - #testo) / 2, 11) | |
| 149 | term.write(testo) | |
| 150 | ||
| 151 | return c | |
| 152 | else | |
| 153 | errore(c["description"]) | |
| 154 | end | |
| 155 | ||
| 156 | ||
| 157 | end | |
| 158 | ||
| 159 | function cpCheck(player) | |
| 160 | a = http.get("http://172.16.20.227//~fabrimat/laser/officecheck.php?player="..player.."&office_code="..code)
| |
| 161 | b = a.readAll() | |
| 162 | os.loadAPI("json")
| |
| 163 | c = json.decode(b) | |
| 164 | ||
| 165 | if c["status"] == "success" then | |
| 166 | return c | |
| 167 | else | |
| 168 | errore(c["description"]) | |
| 169 | end | |
| 170 | ||
| 171 | ||
| 172 | end | |
| 173 | ||
| 174 | function cpConsegna(player, nameNpay) | |
| 175 | ||
| 176 | clear() | |
| 177 | sfondo(colors.blue) | |
| 178 | titolo("Laser Office | Consegna Pacco")
| |
| 179 | colore(colors.black) | |
| 180 | ||
| 181 | term.setCursorPos(1,2) | |
| 182 | print("\nBene, hai un pacco da consegnare.")
| |
| 183 | rs.setOutput("top", false)
| |
| 184 | rs.setOutput("back", false)
| |
| 185 | print("\nDeposita il pacco nello sportello di sotto")
| |
| 186 | print("\n\n\Digita un tasto qualsiasi quando hai messo il pacco nello sportello")
| |
| 187 | os.pullEvent("key")
| |
| 188 | rs.setOutput("top", true)
| |
| 189 | rs.setOutput("back", true)
| |
| 190 | os.sleep(1) | |
| 191 | if rs.getInput("left") then
| |
| 192 | rs.setOutput("top", false)
| |
| 193 | colore(colors.red) | |
| 194 | print("\nInserito materiale non conforme\n\n Attendere...")
| |
| 195 | os.sleep(5) | |
| 196 | rs.setOutput("top", true)
| |
| 197 | cpComplete(player, nameNpay) | |
| 198 | else | |
| 199 | cpComplete(player, nameNpay) | |
| 200 | end | |
| 201 | ||
| 202 | ||
| 203 | ||
| 204 | end | |
| 205 | ||
| 206 | function cpShip() | |
| 207 | ||
| 208 | clear() | |
| 209 | titolo("Laser Office | Consegna Pacco")
| |
| 210 | ||
| 211 | ||
| 212 | colore(colors.black) | |
| 213 | testo = "Inserisci la tua mano nel lettore a destra" | |
| 214 | term.setCursorPos((maxw - #testo) / 2, 10) | |
| 215 | term.write(testo) | |
| 216 | ||
| 217 | os.startTimer(120) | |
| 218 | local event, player = os.pullEvent() | |
| 219 | if event == "player" then | |
| 220 | check = cpCheck(player) | |
| 221 | if check["status"] == "success" then | |
| 222 | clear() | |
| 223 | titolo("Laser Office | Pagamento")
| |
| 224 | ||
| 225 | colore(colors.black) | |
| 226 | term.setCursorPos(1,2) | |
| 227 | print("\nBene, il tuo pacco sta per essere consegnato.")
| |
| 228 | print("\nOra per ricevere il pagamento inserisci il tuo nome utente nPay.")
| |
| 229 | utenteAccettato = false | |
| 230 | while utenteAccettato == false do | |
| 231 | term.setCursorPos(1, 9) | |
| 232 | term.write("Nome utente: ")
| |
| 233 | utente = read() | |
| 234 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
| |
| 235 | tabcheckuser = textutils.unserialize(checkuser) | |
| 236 | if tabcheckuser.stato == "OK" then | |
| 237 | term.setCursorPos(13, 9) | |
| 238 | colore(colors.lime) | |
| 239 | term.write(utente) | |
| 240 | colore(colors.black) | |
| 241 | utenteAccettato = true | |
| 242 | cpConsegna(player, utente) | |
| 243 | else | |
| 244 | term.setCursorPos(13, 9) | |
| 245 | colore(colors.red) | |
| 246 | term.write("Utente errato!")
| |
| 247 | sleep(2) | |
| 248 | term.setCursorPos(13, 9) | |
| 249 | colore(colors.black) | |
| 250 | term.write(" ")
| |
| 251 | end | |
| 252 | end | |
| 253 | ||
| 254 | ||
| 255 | ||
| 256 | ||
| 257 | else | |
| 258 | errore(check["description"]) | |
| 259 | end | |
| 260 | end | |
| 261 | ||
| 262 | ||
| 263 | ||
| 264 | end | |
| 265 | ||
| 266 | function update() | |
| 267 | if not fs.exists(".permaboot") then
| |
| 268 | - | local file fs.open(".permaboot", "w")
|
| 268 | + | local file = fs.open(".permaboot", "w")
|
| 269 | file.writeLine("Permaboooot")
| |
| 270 | file.close() | |
| 271 | end | |
| 272 | shell.run("pastebin get rETd40N3 logo")
| |
| 273 | shell.run("rm json")
| |
| 274 | shell.run("rm star2")
| |
| 275 | shell.run("pastebin get nxbCGJnY star2")
| |
| 276 | shell.run("rm startup")
| |
| 277 | shell.run("mv star2 startup")
| |
| 278 | shell.run("pastebin get ADaQ4War json")
| |
| 279 | end | |
| 280 | ||
| 281 | update() | |
| 282 | code() | |
| 283 | ||
| 284 | sfondo(colors.white) | |
| 285 | term.clear() | |
| 286 | ||
| 287 | if rs.getInput("left") then
| |
| 288 | rs.setOutput("top", false)
| |
| 289 | end | |
| 290 | ||
| 291 | titolo("LASER OFFICE")
| |
| 292 | ||
| 293 | -- 51X 19Y | |
| 294 | colore(colors.black) | |
| 295 | m = paintutils.loadImage("logo")
| |
| 296 | paintutils.drawImage(m, 9, 3) | |
| 297 | term.setCursorPos(14, 11) | |
| 298 | sfondo(colors.white) | |
| 299 | term.write("L O G I S T I C S")
| |
| 300 | ||
| 301 | ||
| 302 | drawFilledBox(15, 15, 35, 17, colors.red) -- FileBox (Consegna Pacco) | |
| 303 | ||
| 304 | testo = "Consegna Pacco" | |
| 305 | term.setCursorPos((maxw - #testo) / 2, 16) | |
| 306 | term.write(testo) | |
| 307 | ||
| 308 | drawFilledBox(42, 16, 48, 18, colors.red) -- FileBox (FAQ) | |
| 309 | ||
| 310 | testo = "F.A.Q" | |
| 311 | term.setCursorPos(43, 17) | |
| 312 | term.write(testo) | |
| 313 | ||
| 314 | colore(colors.black) | |
| 315 | ||
| 316 | while true do | |
| 317 | colore(colors.black) | |
| 318 | local event, par1, par2, par3 = os.pullEventRaw() | |
| 319 | - | if par2 >= 15 and par2 <= 35 and par3 >= 15 and par3 <= 17 and event == "mouse_click" then -- New Return |
| 319 | + | if par1 ~= Nil and par2 ~= Nil and par3 ~= Nil then |
| 320 | - | cpShip() |
| 320 | + | if par2 >= 15 and par2 <= 35 and par3 >= 15 and par3 <= 17 and event == "mouse_click" then -- New Return |
| 321 | - | os.sleep(3) |
| 321 | + | cpShip() |
| 322 | - | os.reboot() |
| 322 | + | os.sleep(3) |
| 323 | os.reboot() | |
| 324 | - | elseif par2 >= 42 and par2 <= 49 and par3 >= 16 and par3 <= 18 and event == "mouse_click" then -- FAQ |
| 324 | + | elseif par2 >= 42 and par2 <= 49 and par3 >= 16 and par3 <= 18 and event == "mouse_click" then -- FAQ |
| 325 | - | faq() |
| 325 | + | faq() |
| 326 | - | os.reboot() |
| 326 | + | |
| 327 | end | |
| 328 | - | print("\n\n ".. event)
|
| 328 | + | |
| 329 | end | |
| 330 | ||
| 331 | os.sleep(45) | |
| 332 | os.reboot() |