Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function showacc()
- cteniD()
- cteniF()
- print("David: " .. ucetD)
- print("Filip: " .. ucetF)
- print("---------------")
- print(" ")
- end
- function zapisD()
- local fileD = fs.open("ucetDf", "w")
- fileD.writeLine(ucetD)
- fileD.close()
- end
- function zapisF()
- local fileF = fs.open("ucetFf", "w")
- fileF.writeLine(ucetF)
- fileF.close()
- end
- function cteniD()
- local fileD = fs.open("ucetDf", "r")
- ucetDs = fileD.readLine()
- ucetD = tonumber(ucetDs)
- if ucetD == nil then
- ucetD = 0
- end
- fileD.close()
- end
- function cteniF()
- local fileF = fs.open("ucetFf", "r")
- ucetFs = fileF.readLine()
- ucetF = tonumber(ucetFs)
- if ucetF == nil then
- ucetF = 0
- end
- fileF.close()
- end
- --zacatek
- if fs.exists("ucetDf") then
- showacc()
- rednet.open("top")
- while true do
- local id, msgwho, protocol = rednet.receive("kdo")
- local id, msghowmuch, protocol = rednet.receive("kolik")
- vydelek = tonumber(msghowmuch)
- if msgwho == "David"
- then
- cteniD()
- showacc()
- ucetD = ucetD + vydelek
- zapisD()
- end
- if msgwho == "Filip"
- then
- cteniF()
- ucetF = ucetF + vydelek
- zapisF()
- end
- showacc()
- end
- else
- local ucetD = 0
- local ucetF = 0
- zapisD()
- zapisF()
- end
- os.reboot()
Add Comment
Please, Sign In to add comment