-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcc.lua
344 lines (277 loc) · 8.69 KB
/
cc.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
-- CFG Program Files
local maxw, maxh = term.getSize()
local printer = peripheral.wrap("back")
os.pullEvent = os.pullEventRaw
-- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
local function drawPixelInternal(xPos, yPos)
term.setCursorPos(xPos, yPos)
term.write(" ")
end
Gplayer = ""
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 print_Page(message)
if printer.getPaperLevel() == 0 then -- If there is no paper in the printer
errore("La carta nella stampante è finita!")
end
if printer.getInkLevel() == 0 then -- If there is no ink in the printer
error("L'inchiostro nella stampante è finita!")
end
-- There is paper and ink in the printer, we can now print a page
if printer.newPage() then
printer.write("Ricevuta PNRF")
printer.setCursorPos(1, 3)
printer.write("* Frequenza: "..message)
printer.setCursorPos(1, 8)
printer.write("Grazie per usare PNRF")
printer.setPageTitle("PNRF - Ricevuta")
printer.endPage()
else
errore("Stampante inceppata!")
end
end
function make_payment(player, amount)
clear()
titolo("PNFR HUB | Pagamento")
colore(colors.black)
term.setCursorPos(1,3)
print("Inserisce le credenziali nPay\nper comprare il pagamento\nPrezzo da pagare: "..amount.." IC")
term.setCursorPos(1,7)
term.write("Nome utente:")
term.setCursorPos(1,9)
term.write("Password:")
term.setCursorPos(14,7)
username = read()
term.setCursorPos(11,9)
password = read("*")
a = http.get("https://pnrf.rgbcraft.com/api/do/payments?player="..player.."&username="..username.."&password="..password.."&amount="..amount)
if a ~= nil and a ~= "" then
b = a.readAll()
c = textutils.unserialize(b)
a.close()
if c['status'] == "OK" then
clear()
titolo("PNFR HUB | Pagamento completato")
sfondo(colors.white)
colore(colors.black)
testo = "Frequenza assegnata: "..c['frequency']
term.setCursorPos((maxw - #testo) / 2, 11)
term.write(testo)
print("\n Stiamo stampando la ricevuta..")
os.sleep(1)
print_Page(c['frequency'])
os.sleep(8)
os.reboot()
else
errore(c['detail'])
end
else
errore("Server non raggiungibile")
end
os.sleep(5)
end
function new_frequency(player)
a = http.get("https://pnrf.rgbcraft.com/api/check/newfrequency?player="..player)
if a ~= nil and a ~= "" then
b = a.readAll()
c = textutils.unserialize(b)
a.close()
if c['status'] == "OK" then
clear()
titolo("PNFR HUB | Nuova Frequenza")
colore(colors.black)
testo = "Clicca qualsiasi tasto per confermare"
testo2 = "dovrai pagare: "..c['price']
testo3 = "Al momento hai ".. c['frequency'].." frequenza/e"
term.setCursorPos((maxw - #testo) / 2, 10)
term.write(testo)
term.setCursorPos((maxw - #testo2) / 2, 11)
term.write(testo2)
term.setCursorPos((maxw - #testo3) / 2, 13)
term.write(testo3)
os.pullEvent("key")
make_payment(player, c['price'])
elseif c['status'] == "TMF" then
clear()
titolo("PNFR HUB | Nuova Frequenza")
colore(colors.black)
testo = "Hai troppe frequenze!!, contatatta legoz"
term.setCursorPos((maxw - #testo) / 2, 11)
term.write(testo)
os.sleep(5)
os.reboot()
else
os.reboot()
end
else
errore("Server non raggiungibile")
end
end
function playerCheck(player)
a = http.get("https://pnrf.rgbcraft.com/api/checkplayer?player="..player)
if a ~= nil and a ~= "" then
b = a.readAll()
c = textutils.unserialize(b)
a.close()
Gplayer = player
if c['status'] == "OK" then
clear()
titolo("PNFR HUB | Nuova Frequenza")
colore(colors.black)
testo = "Sei un nuovo utente!"
term.setCursorPos((maxw - #testo) / 2, 11)
term.write(testo)
os.sleep(1)
new_frequency(player)
elseif c['status'] == "NP" then
clear()
titolo("PNFR HUB | Nuova Frequenza")
colore(colors.black)
testo = "Utente già registrato.. ASPETTA!"
term.setCursorPos((maxw - #testo) / 2, 11)
term.write(testo)
os.sleep(1)
new_frequency(player)
else
os.reboot()
end
else
errore("Server non raggiungibile")
end
end
function new_Frequence()
clear()
titolo("PNFR HUB | Nuova Frequenza")
colore(colors.black)
testo = "Clicca il sensore posto al lato/sotto"
term.setCursorPos((maxw - #testo) / 2, 11)
term.write(testo)
os.startTimer(120)
local event, player = os.pullEvent()
if event == "player" then
playerCheck(player)
end
end
function faq()
clear()
titolo("PNFR 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 update()
if not fs.exists(".permaboot") then
local file fs.open(".permaboot", "w")
file.writeLine("Permaboooot")
file.close()
os.reboot()
end
shell.run("rm startup")
shell.run("pastebin get sg8epUiQ star")
shell.run("star")
shell.run("mv star startup")
end
update()
sfondo(colors.white)
term.clear()
titolo("PNRF HUB")
-- 51X 19Y
colore(colors.black)
sfondo(colors.white)
drawFilledBox(15, 11, 35, 13, colors.red) -- FileBox (Consegna Pacco)
testo = "Nuova Frequenza"
term.setCursorPos((maxw - #testo) / 2, 12)
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 >= 11 and par3 <= 13 and event == "mouse_click" then -- New Return
new_Frequence()
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
end
os.sleep(45)
os.reboot()