SHOW:
|
|
- or go back to the newest paste.
1 | local maxw, maxh = term.getSize() | |
2 | ||
3 | function creditoInsufficiente() | |
4 | clearRed() | |
5 | print("Credito insufficiente.") | |
6 | print("") | |
7 | print("Premere un tasto per uscire") | |
8 | os.pullEvent("key") | |
9 | os.reboot() | |
10 | end | |
11 | ||
12 | function prodottoEsaurito() | |
13 | clearRed() | |
14 | print("Prodotto esaurito.") | |
15 | print("") | |
16 | print("Premere un tasto per uscire") | |
17 | os.pullEvent("key") | |
18 | os.reboot() | |
19 | end | |
20 | ||
21 | -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
22 | local function drawPixelInternal(xPos, yPos) | |
23 | term.setCursorPos(xPos, yPos) | |
24 | term.write(" ") | |
25 | end | |
26 | ||
27 | local tColourLookup = {} | |
28 | for n = 1, 16 do | |
29 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1) | |
30 | end | |
31 | ||
32 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
33 | if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~= | |
34 | "number" or type(endY) ~= "number" or | |
35 | (nColour ~= nil and type(nColour) ~= "number") then | |
36 | error("Expected startX, startY, endX, endY, colour", 2) | |
37 | end | |
38 | ||
39 | startX = math.floor(startX) | |
40 | startY = math.floor(startY) | |
41 | endX = math.floor(endX) | |
42 | endY = math.floor(endY) | |
43 | ||
44 | if nColour then term.setBackgroundColor(nColour) end | |
45 | if startX == endX and startY == endY then | |
46 | drawPixelInternal(startX, startY) | |
47 | return | |
48 | end | |
49 | ||
50 | local minX = math.min(startX, endX) | |
51 | if minX == startX then | |
52 | minY = startY | |
53 | maxX = endX | |
54 | maxY = endY | |
55 | else | |
56 | minY = endY | |
57 | maxX = startX | |
58 | maxY = startY | |
59 | end | |
60 | ||
61 | for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end | |
62 | end | |
63 | ||
64 | function clear() | |
65 | sfondo(colors.black) | |
66 | term.clear() | |
67 | term.setCursorPos(1, 1) | |
68 | end | |
69 | ||
70 | function clearRed() | |
71 | sfondo(colors.red) | |
72 | term.clear() | |
73 | term.setCursorPos(1, 1) | |
74 | end | |
75 | ||
76 | function colore(sfumatura) term.setTextColour(sfumatura) end | |
77 | ||
78 | function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end | |
79 | ||
80 | function fineColore() term.setTextColour(colours.white) end | |
81 | ||
82 | function fineSfondo() term.setBackgroundColour(colours.black) end | |
83 | ||
84 | function titolo(testo) | |
85 | drawFilledBox(1, 1, maxw, 1, colors.yellow) | |
86 | term.setCursorPos((maxw - #testo) / 2, 1) | |
87 | colore(colors.black) | |
88 | term.write(testo) | |
89 | sfondo(colors.blue) | |
90 | end | |
91 | ||
92 | function errore(errore) | |
93 | sfondo(colors.red) | |
94 | colore(colors.white) | |
95 | term.clear() | |
96 | term.setCursorPos(1, 1) | |
97 | titolo("Errore irreversibile") | |
98 | term.setCursorPos(1, 3) | |
99 | sfondo(colors.red) | |
100 | colore(colors.white) | |
101 | print(errore) | |
102 | print("\n\n\nAttendere qualche secondo...") | |
103 | os.sleep(5) | |
104 | os.reboot() | |
105 | end | |
106 | ||
107 | sfondo(colours.blue) | |
108 | term.clear() | |
109 | term.setCursorPos(1, 1) | |
110 | - | titolo("Pagamento rapido con Nebraska Pay") |
110 | + | titolo("Le uova di Putin") |
111 | sfondo(colours.blue) | |
112 | colore(colors.white) | |
113 | print( | |
114 | "\n\nInserire i propri dati. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.") | |
115 | ||
116 | -- nomeutente | |
117 | term.setCursorPos(1, 9) | |
118 | term.write("Nome utente:") | |
119 | term.setCursorPos(15, 9) | |
120 | fineColore() | |
121 | utenteAccettato = false | |
122 | conteggioErrori = 0 | |
123 | while utenteAccettato == false do | |
124 | utente = read() | |
125 | checkuser = http.get( | |
126 | "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. | |
127 | utente).readAll() | |
128 | tabcheckuser = textutils.unserialize(checkuser) | |
129 | if tabcheckuser.stato == "OK" then | |
130 | term.setCursorPos(15, 9) | |
131 | colore(colours.lime) | |
132 | term.write(utente) | |
133 | fineColore() | |
134 | utenteAccettato = true | |
135 | else | |
136 | term.setCursorPos(15, 9) | |
137 | colore(colours.red) | |
138 | term.write("Utente errato! ") | |
139 | sleep(2) | |
140 | term.setCursorPos(15, 9) | |
141 | fineColore() | |
142 | term.write(" ") | |
143 | term.setCursorPos(15, 9) | |
144 | conteggioErrori = conteggioErrori + 1 | |
145 | if conteggioErrori > 2 then | |
146 | term.setCursorPos(15, 9) | |
147 | colore(colours.red) | |
148 | errore("Troppi tentativi di immissione errati ") | |
149 | end | |
150 | end | |
151 | end | |
152 | colore(colours.white) | |
153 | term.setCursorPos(1, 11) | |
154 | term.write("Password:") | |
155 | term.setCursorPos(15, 11) | |
156 | conteggioErrori = 0 | |
157 | passAccettata = false | |
158 | while passAccettata == false do | |
159 | fineColore() | |
160 | password = read("#") | |
161 | colore(colours.black) | |
162 | checkuser = http.get( | |
163 | "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. | |
164 | password .. "&richiesta=addebito&valore=0&utente=" .. | |
165 | utente).readAll() | |
166 | risposta = textutils.unserialize(checkuser) | |
167 | if risposta.stato == "OK" then | |
168 | term.setCursorPos(15, 11) | |
169 | colore(colours.lime) | |
170 | term.write("############## ") | |
171 | fineColore() | |
172 | passAccettata = true | |
173 | else | |
174 | term.setCursorPos(15, 11) | |
175 | colore(colours.red) | |
176 | term.write("Password errata! ") | |
177 | conteggioErrori = conteggioErrori + 1 | |
178 | sleep(2) | |
179 | term.setCursorPos(15, 11) | |
180 | term.write(" ") | |
181 | term.setCursorPos(15, 11) | |
182 | if conteggioErrori > 2 then | |
183 | term.setCursorPos(15, 11) | |
184 | colore(colours.red) | |
185 | errore("Troppi tentativi di immissione errati") | |
186 | end | |
187 | end | |
188 | end | |
189 | ||
190 | while true do | |
191 | clear() | |
192 | - | titolo("HIGHLAND MINING") |
192 | + | titolo("LE UOVA DI PUTIN ") |
193 | colore(colors.white) | |
194 | sfondo(colors.red) | |
195 | term.setCursorPos(35, 1) | |
196 | term.write(" CHIUDI SESSIONE ") | |
197 | fineColore() | |
198 | fineSfondo() | |
199 | print("") | |
200 | print("\nProdotto Prezzo") | |
201 | p = {} | |
202 | -- nome, prezzo, id, meta, colore cavo | |
203 | - | p[1] = {"Salnitro", 1500, 458, 1, 1} |
203 | + | p[1] = {"Uova", 4, 0, 0, 0} |
204 | ||
205 | ypos = 4 | |
206 | for k, v in pairs(p) do | |
207 | term.setCursorPos(1, ypos) | |
208 | term.write(v[1]) | |
209 | term.setCursorPos(20, ypos) | |
210 | term.write(v[2]) | |
211 | term.setCursorPos(30, ypos) | |
212 | if alt == false then | |
213 | sfondo(colors.lightBlue) | |
214 | alt = true | |
215 | else | |
216 | sfondo(colors.blue) | |
217 | alt = false | |
218 | end | |
219 | colore(colors.white) | |
220 | term.write(" Compra ") | |
221 | fineSfondo() | |
222 | fineColore() | |
223 | ypos = ypos + 1 | |
224 | end | |
225 | ||
226 | while true do | |
227 | ||
228 | local event, par1, x, y = os.pullEvent("mouse_click") | |
229 | if event == "mouse_click" and y > 3 and y < 5 then | |
230 | prodotto = p[y - 3] | |
231 | break | |
232 | elseif event == "mouse_click" and y == 1 then | |
233 | os.reboot() | |
234 | end | |
235 | sleep(1) | |
236 | end | |
237 | clear() | |
238 | ||
239 | print(prodotto[1]) | |
240 | ||
241 | if colors.test(redstone.getBundledInput("bottom"), prodotto[5]) == true then | |
242 | prodottoEsaurito() | |
243 | end | |
244 | term.clear() | |
245 | term.setCursorPos(1, 1) | |
246 | titolo("Paga con Nebraska Pay") | |
247 | sfondo(colours.black) | |
248 | colore(colors.white) | |
249 | print("\n\nSaldo disponibile: " .. risposta.saldo .. " IC") | |
250 | if tonumber(risposta.saldo) >= tonumber(prodotto[2]) then | |
251 | prezzoAccettato = true | |
252 | else | |
253 | errore("Disponibilità insufficiente!") | |
254 | end | |
255 | term.setCursorPos(1, 3) | |
256 | term.write("Invio di ") | |
257 | term.write(prodotto[2]) | |
258 | term.write(" IC a favore di ") | |
259 | term.write("Highland Mining") | |
260 | print("\n\nConfermare l'operazione?") | |
261 | colore(colors.yellow) | |
262 | print("\n\nInvia il denaro Annulla") | |
263 | while true do | |
264 | event, key, x, y = os.pullEvent() | |
265 | if event == "mouse_click" and x < 16 and y == 8 then | |
266 | inviaDenaro = http.get( | |
267 | "http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. | |
268 | password .. "&utente=" .. utente .. | |
269 | "&richiesta=trasferimento&valore=" .. | |
270 | - | prodotto[2] .. "&beneficiario=HighlandMining&causale=Merce%20ingrosso%20Fornost") |
270 | + | prodotto[2] .. "&beneficiario=managerputin") |
271 | .readAll() | |
272 | risultatoInvio = textutils.unserialize(inviaDenaro) | |
273 | if risultatoInvio.stato == "OK" then | |
274 | break | |
275 | else | |
276 | clear() | |
277 | errore("Errore durante il pagamento") | |
278 | end | |
279 | elseif event == "mouse_click" and x > 18 and y == 8 then | |
280 | errore("Pagamento annullato dall'utente.") | |
281 | end | |
282 | end | |
283 | clear() | |
284 | titolo("Erogazione in corso") | |
285 | fineSfondo() | |
286 | fineColore() | |
287 | print("\n\nErogazione di un vagone di " .. prodotto[1] .. " in corso...") | |
288 | print("\nATTENZIONE: IMPIANTO LOGISTIC LENTO, ATTENDERE") | |
289 | sfondo(colors.red) | |
290 | colore(colors.white) | |
291 | ben = peripheral.wrap("back") | |
292 | ben.makeRequest(ben.getItemIdentifierIDFor(prodotto[3], prodotto[4]), 3456) | |
293 | sleep(10) | |
294 | end | |
295 |