View difference between Paste ID: BSbJprkC and ZPfZwZ7q
SHOW: | | - or go back to the newest paste.
1
local slot = 0
2
local myID = os.getComputerID()
3
  
4-
function hotovo()
4+
5-
 hotovot = {}
5+
6
   
7
   fileCO = fs.open("currentoffer", "r")
8
   local line = fileCO.readAll()
9
   fileCO.close()
10
   offertable = textutils.unserialize(line)
11
   
12-
 sleep(180)
12+
13-
end
13+
14
   cena = offertable[3]
15-
function password() 
15+
16-
 passwordD = "david"
16+
17
   print("Objednavka: ", pocet, jidlo)
18
   print("Vyplata: ", cena, " kreditu.")
19
    passwordD = "david"
20
 passwordF = "filip"
21
  
22
 local heslonerozpoznano = true
23
 while heslonerozpoznano do  
24
   write("Heslo: ")
25
   local input = read("*")
26
   if input == passwordD
27
   then 
28
      heslonerozpoznano = false
29
      print ("Objednavka prijata. Na ucet David bylo pripsano " .. cena .. " kreditu.")
30
      rednet.open("top")
31
	  rednet.broadcast("poptavka", "ucel")
32-
      hotovo()
32+
33
      rednet.broadcast(cena,"kolik")
34
      slot = slot - 1
35
      hotovot = {}
36
 hotovot[4] = myID
37
 hotovot[5] = "F"
38
 local msg = textutils.serialize(hotovot)
39
 rednet.open("top")
40
 rednet.broadcast(msg, "offer")
41
 fs.delete("currentoffer")
42
 sleep(3)
43-
      hotovo()
43+
44
   elseif input == passwordF
45
   then
46
      heslonerozpoznano = false
47
      print ("Objednavka prijata. Na ucet Filip bylo pripsano " .. cena .. " kreditu.")
48
      rednet.open("top")
49-
end
49+
50
      rednet.broadcast("Filip","kdo")
51-
function vyplata()
51+
52-
 sendtable()
52+
53
      hotovot = {}
54
 hotovot[4] = myID
55
 hotovot[5] = "F"
56-
   sleep(180)
56+
57
 rednet.open("top")
58
 rednet.broadcast(msg, "offer")
59
 fs.delete("currentoffer")
60
 sleep(3)
61
           
62
   else print("Heslo nerozpoznano")
63
   sleep(1)
64
   end
65
  end
66
 
67
 else
68
   local vacancy = 1
69
   while vacancy == 1 do
70
    rednet.open("top")
71
    while slot == 0 do
72
   slot = slot + 1
73
   n = math.random(1,192)
74-
   password()
74+
75
   
76-
end
76+
77
   pocet = 128
78-
function sendtable()
78+
79-
 cena = cenajidla * pocet
79+
80
   
81
   if n == 1 then
82
    slot = slot - 1
83
          
84
   elseif n == 2 then
85
    jidlo = "x PMP spenat"
86-
 t[6] = "Glucksgefuhlausloser"
86+
87
        
88
   elseif n == 3 then 
89
    jidlo = "x PMP okurka"
90-
end
90+
91
            
92
   elseif n == 4 then
93-
function offergen()
93+
94-
 while slot == 0 do
94+
95
       
96-
   n = math.random(1,152)
96+
97
    jidlo = "x PMP salat" 
98
    cenajidla = 10
99
   
100
   elseif n == 6 then
101
    jidlo = "x PMP kukurice"
102
    cenajidla = 5
103
      
104
   elseif n == 7 then
105
    jidlo = "x obili"
106
    cenajidla = 5
107
    
108
   elseif n == 8 then
109
    jidlo = "x cervena repa"
110
    cenajidla = 10
111
    
112
   elseif n == 9 then
113
    jidlo = "x meloun"
114
    cenajidla = 5
115
    
116
   elseif n == 10 then
117
    jidlo = "x PMP divoka ryze"
118
    cenajidla = 5
119
    
120
   elseif n == 11 then
121
    jidlo = "x jehneci"
122
    cenajidla = 50
123
         
124
   elseif n == 12 then
125
    jidlo = "x hovezi"
126
    cenajidla = 15
127
         
128
   elseif n >= 13 and n<= 18 then
129
	cenajidla = 25
130
	local ryba = math.random(1, 17)
131
	if     ryba == 1  then jidlo = "x ryba"
132
    elseif ryba == 2  then jidlo = "x HC raw bass"
133
    elseif ryba == 3  then jidlo = "x HC raw carp" 
134
    elseif ryba == 4  then jidlo = "x HC raw catfish" 
135
    elseif ryba == 5  then jidlo = "x HC raw grouper"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
136
    elseif ryba == 6  then jidlo = "x HC raw herring"                    
137
    elseif ryba == 7  then jidlo = "x HC raw tilapia"
138
    elseif ryba == 8  then jidlo = "x HC raw tuna"
139
    elseif ryba == 9  then jidlo = "x HC raw walleye"
140
    elseif ryba == 10 then jidlo = "x HC raw green heart fish"
141
	elseif ryba == 11 then jidlo = "x HC raw charr"
142
	elseif ryba == 12 then jidlo = "x HC raw mudfish"
143
	elseif ryba == 13 then jidlo = "x HC raw trout"
144
	elseif ryba == 14 then jidlo = "x HC raw anchovy"
145
	elseif ryba == 15 then jidlo = "x HC raw perch"
146
	elseif ryba == 16 then jidlo = "x HC raw snapper"
147
	elseif ryba == 17 then jidlo = "x HC raw eel"
148
	end
149
150
   elseif n == 19 then
151
    jidlo = "x HC raw crab"
152
    cenajidla = 25
153
    
154
   elseif n == 20 then
155
    jidlo = "x HC raw crayfish"
156
    cenajidla = 25
157
                                            
158
   elseif n == 21 then
159
    jidlo = "x HC raw frog"
160
    cenajidla = 25
161
    
162
   elseif n == 22 then
163
    jidlo = "x HC raw octopus"
164
    cenajidla = 25
165
        
166
   elseif n == 23 then 
167
    jidlo = "x HC raw scallop"
168
    cenajidla = 25
169
         
170
   elseif n == 24 then
171
    jidlo = "x HC raw shrimp"
172
    cenajidla = 25
173
        
174
   elseif n == 25 then
175
    jidlo = "x HC raw snail"
176
    cenajidla = 25
177
     
178
   elseif n == 26 then
179
    jidlo = "x HC raw turtle"
180
    cenajidla = 25
181
           
182
   elseif n == 27 then
183
    jidlo = "x HC raw turkey"
184
    cenajidla = 50
185
        
186
   elseif n == 28 then 
187
    jidlo = "x HC raw venison"
188
    cenajidla = 50
189
        
190
   elseif n == 29 then
191
    jidlo = "x HC raw rabbit"
192
    cenajidla = 50
193
       
194
   elseif n == 30 then
195
    jidlo = "x HC raw calamari"
196
    cenajidla = 25
197
            
198
   elseif n == 31 then
199
    jidlo = "x losos"			
200
    cenajidla = 30                                                                   
201
                
202
   elseif n == 32 then 
203
    jidlo = "x PMP rajce"
204
    cenajidla = 10
205
       
206
   elseif n == 33 then
207
    jidlo = "x PMP cibule"
208
    cenajidla = 10
209
        
210
   elseif n == 34 then
211
    jidlo = "x mrkev"
212
    cenajidla = 10
213
        
214
   elseif n == 35 then 
215
    jidlo = "x PMP peanuts"
216
    cenajidla = 10     
217
   
218
   elseif n == 36 then
219
    jidlo = "x kaktus"
220
    cenajidla = 15
221
        
222
   elseif n == 37 then
223
    jidlo = "x kure"
224
    cenajidla = 10
225
        
226
   elseif n == 38 then
227
    jidlo = "x veprove"
228
    cenajidla = 20
229
    
230
   elseif n == 39 then
231
    jidlo = "x cukr"
232
    cenajidla = 10
233
        
234
   elseif n == 40 then                
235
    jidlo = "x PMP blueberry"
236
    cenajidla = 5
237
    
238
   elseif n == 41 then
239
    jidlo = "x PMP strawberry"
240
    cenajidla = 5
241
        
242
   elseif n == 42 then
243
    jidlo = "x PMP blackberry"
244
    cenajidla = 5
245
        
246
   elseif n == 43 then
247
    jidlo = "x PMP whiteberry" 
248
    cenajidla = 5
249
   
250
   elseif n == 44 then
251
    jidlo = "x PMP gooseberry"
252
    cenajidla = 5
253
       
254
   elseif n == 45 then
255
    jidlo = "x PMP beautyberry"
256
    cenajidla = 5                                                                           
257
     
258
   elseif n == 46 then
259
    jidlo = "x PMP orangeberry"
260
    cenajidla = 5
261
    
262
   elseif n == 47 then
263
    jidlo = "x brambory"
264
    cenajidla = 5
265
266
  elseif n == 48 then
267
    jidlo = "x HC avocado"
268
    cenajidla = 5
269
270
  elseif n == 49 then
271
    jidlo = "x HC olive"
272
    cenajidla = 5
273
274
  elseif n == 50 then
275
    jidlo = "x HC pea"
276
    cenajidla = 5
277
278
  elseif n == 51 then
279
    jidlo = "x HC chilli"
280
    cenajidla = 5
281
 
282
  elseif n == 52 then
283
    jidlo = "x HC plum"
284
    cenajidla = 5
285
286
  elseif n == 53 then
287
    jidlo = "x HC lemon"
288
    cenajidla = 5
289
290
  elseif n == 54 then
291
    jidlo = "x HC tea leaf"
292
    cenajidla = 5
293
294
  elseif n == 55 then
295
    jidlo = "x HC soybean"
296
    cenajidla = 5
297
298
  elseif n == 56 then
299
    jidlo = "x HC asparagus"
300
    cenajidla = 5
301
302
  elseif n == 57 then
303
    jidlo = "x HC garlic"
304
    cenajidla = 5
305
306
  elseif n == 58 then
307
    jidlo = "x HC rhubarb"
308
    cenajidla = 5
309
310
  elseif n == 59 then
311
    jidlo = "x HC grape"
312
    cenajidla = 5
313
314
  elseif n == 60 then
315
    jidlo = "x HC mustard"
316
    cenajidla = 5
317
   
318
  elseif n == 61 then
319
    jidlo = "x HC coconut"
320
    cenajidla = 5
321
  
322
  elseif n == 62 then
323
    jidlo = "x HC maple syrup"
324
    cenajidla = 10  
325
326
  elseif n == 63 then
327
    jidlo = "x HC orange"
328
    cenajidla = 5
329
330
  elseif n == 64 then
331
    jidlo = "x HC chestnut"
332
    cenajidla = 5
333
334
 elseif n == 65 then
335
    jidlo = "x HC cherry"
336
	cenajidla = 5
337
338
 elseif n == 66 then
339
	jidlo = "HC banana"
340
	cenajidla = 5
341
342
 elseif n == 67 then
343
	jidlo = "HC cashew"
344
	cenajidla = 5
345
346
 elseif n == 68 then
347-
    cenajidla = 20  
347+
	jidlo = "HC grapefruit"
348
	cenajidla = 5
349
350
 elseif n == 69 then
351
	jidlo = "HC cinnamon"
352
	cenajidla = 10
353
	
354
 elseif n == 70 then
355
	jidlo = "HC vanilla bean"
356
	cenajidla = 5
357-
  elseif n >= 65 and n<= 75 then
357+
358
 elseif n == 71 then
359
 	jidlo = "HC fig"
360
	cenajidla = 5
361-
   elseif n >= 76 and n<= 152 then
361+
362
 elseif n == 72 then
363
	jidlo = "HC almond"
364
	cenajidla = 5
365
366-
end
366+
 elseif n == 73 then
367
	jidlo = "HC pomegranate"
368-
function checkreq()
368+
	cenajidla = 5
369
370
 elseif n == 74 then
371
	jidlo = "HC pepper"
372
	cenajidla = 5
373
374
 elseif n == 75 then
375
	jidlo = "HC broccoli"
376
	cenajidla = 5
377
 
378
 elseif n == 76 then
379
	jidlo = "HC coffee"
380
	cenajidla = 5
381
382
 elseif n == 77 then
383
	jidlo = "HC lime"
384-
   password()
384+
	cenajidla = 5
385
386
 elseif n == 78 then
387
	jidlo = "HC date"
388
	cenajidla = 5
389
390-
    offergen()
390+
 elseif n == 79 then
391
	jidlo = "HC ginger"
392
	cenajidla = 5
393-
    vyplata() 
393+
394
 elseif n == 80 then
395
	jidlo = "HC zucchini"
396
	cenajidla = 5
397-
 end   
397+
398-
end
398+
 elseif n == 81 then
399
 	jidlo = "HC honey"
400
	cenajidla = 5
401
402-
checkreq()
402+
 elseif n == 82 then
403
	jidlo = "PC wine grapes"
404
	cenajidla = 5
405
406
  elseif n >= 83 and n<= 95 then
407
    jidlo = "x jidlo"
408
    cenajidla = 10
409
        
410
   elseif n >= 96 and n<= 192 then
411
   slot = slot - 1 
412
               
413
  end
414
  end
415
  
416
    vacancy = vacancy - 1
417
     cena = cenajidla * pocet
418
 local t = {}
419
 t[1] = pocet
420
 t[2] = jidlo
421
 t[3] = cena
422
 t[4] = myID
423
 t[5] = "F"
424
 t[6] = "David's Corner"
425
 local msg = textutils.serialize(t)
426
 rednet.open("top")
427
 rednet.broadcast(msg, "offer")
428
429
430
 local id, msg = rednet.receive(2)
431
 if msg == "full" then
432
   sleep(3)
433
   slot = 0
434
   
435
 else
436
   print("-----------------------------")
437
   print("Objednavka: ", pocet, jidlo)
438
   print("Vyplata: ", cena," kreditu.")
439
   
440
   local savetable = {}
441
   cena = cenajidla * pocet
442
   savetable[1] = pocet
443
   savetable[2] = jidlo
444
   savetable[3] = cena
445
   
446
   local fileWT = fs.open("currentoffer", "w")
447
   fileWT.write(textutils.serialize(savetable))
448
   fileWT.close()
449
   
450
    passwordD = "david"
451
 passwordF = "filip"
452
  
453
 local heslonerozpoznano = true
454
 while heslonerozpoznano do  
455
   write("Heslo: ")
456
   local input = read("*")
457
   if input == passwordD
458
   then 
459
      heslonerozpoznano = false
460
      print ("Objednavka prijata. Na ucet David bylo pripsano " .. cena .. " kreditu.")
461
      rednet.open("top")
462
	  rednet.broadcast("poptavka", "ucel")
463
      rednet.broadcast("David","kdo")
464
      rednet.broadcast(cena,"kolik")
465
      slot = slot - 1
466
      hotovot = {}
467
 hotovot[4] = myID
468
 hotovot[5] = "F"
469
 local msg = textutils.serialize(hotovot)
470
 rednet.open("top")
471
 rednet.broadcast(msg, "offer")
472
 fs.delete("currentoffer")
473
 sleep(3)
474
      
475
   elseif input == passwordF
476
   then
477
      heslonerozpoznano = false
478
      print ("Objednavka prijata. Na ucet Filip bylo pripsano " .. cena .. " kreditu.")
479
      rednet.open("top")
480
	  rednet.broadcast("poptavka", "ucel")
481
      rednet.broadcast("Filip","kdo")
482
      rednet.broadcast(cena,"kolik")
483
      slot = slot - 1
484
      hotovot = {}
485
 hotovot[4] = myID
486
 hotovot[5] = "F"
487
 local msg = textutils.serialize(hotovot)
488
 rednet.open("top")
489
 rednet.broadcast(msg, "offer")
490
 fs.delete("currentoffer")
491
 sleep(3)
492
           
493
   else print("Heslo nerozpoznano")
494
   sleep(1)
495
   end
496
  end
497
  end 
498
    vacancy = vacancy + 1 
499
   end
500
  end      
501
 end