View difference between Paste ID: 40iCxqrw and xkdT1iBG
SHOW: | | - or go back to the newest paste.
1
function showacc()
2
 cteniD()
3
 cteniF()
4
 print("David: " .. ucetD)
5
 print("Filip: " .. ucetF)
6
 print("---------------")
7
 print(" ") 
8
end 
9
10
function zapisD()
11
 local fileD = fs.open("ucetDf", "w")
12
 fileD.writeLine(ucetD)
13
 fileD.close() 
14
end
15
16
function zapisF()
17
 local fileF = fs.open("ucetFf", "w")
18
 fileF.writeLine(ucetF)
19
 fileF.close()
20
end 
21
22
function cteniD()
23
 local fileD = fs.open("ucetDf", "r")
24
 ucetDs = fileD.readLine()
25
 ucetD = tonumber(ucetDs)
26
 if ucetD == nil then
27
  ucetD = 0
28
 end
29
 fileD.close()
30
end
31
32
function cteniF()
33
 local fileF = fs.open("ucetFf", "r")
34
 ucetFs = fileF.readLine()
35
 ucetF = tonumber(ucetFs)
36
 if ucetF == nil then
37
  ucetF = 0
38
 end
39
 fileF.close() 
40
end
41
42
43
44
--zacatek
45
if fs.exists("ucetDf") then
46
47
showacc()
48-
rednet.open('right')
48+
rednet.open("top")
49
while true do
50
 local id, msgwho, protocol = rednet.receive("kdo")
51-
 local id, msghowmuch, protocol = rednet. receive("kolik")
51+
 local id, msghowmuch, protocol = rednet.receive("kolik")
52
 vydelek = tonumber(msghowmuch)
53
  
54
  if msgwho == "David"
55
  then 
56
  cteniD()
57
  showacc()
58
  ucetD = ucetD + vydelek
59
  zapisD()
60
  end
61
  
62
  if msgwho == "Filip"
63
  then
64
  cteniF()
65
  ucetF = ucetF + vydelek
66
  zapisF()  
67
  end
68
 
69
  showacc()
70
  
71
  end
72
73
else
74-
 local ucetD = 1000
74+
 local ucetD = 0
75-
 local ucetF = 1000
75+
 local ucetF = 0
76
 zapisD()
77
 zapisF()
78
  
79
end
80
os.reboot()