Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --term.clear()
- --term.setCursorPos(1,1)
- print("Running Results Server.")
- rednet.open("top")
- while true do
- id,command = rednet.receive()
- if command == "vote" then
- local id,ballot = rednet.receive(10)
- local id,result = rednet.receive(10)
- print(ballot)
- print(result)
- hrResult = fs.open("disk/results/"..ballot,"r")
- cResults = textutils.unserialize(hrResult.readLine())
- hrResult.close()
- if result == "yes" then
- slot = 1
- end
- if result == "no" then
- slot = 2
- end
- cResults[slot] = cResults[slot]+1
- hwResult = fs.open("disk/results/"..ballot,"w")
- hwResult.writeLine(textutils.serialize(cResults))
- hwResult.close()
- end
- if command == "access" then
- local id,ballot = rednet.receive()
- local rPath = "disk/results/"..ballot
- hrResult = fs.open(rPath,"r")
- rednet.send(id,hrResult.readLine())
- hrResult.close()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment