Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- rednet.open("top")
- local stackerscores = fs.open("stackerscores","r")
- local data = stackerscores.readAll()
- stackerscores.close()
- textutils.unserialise(data)
- local stacker = {data}
- print("Stacker:")
- local breakoutscores = fs.open("breakoutscores","r")
- local data = breakoutscores.readAll()
- breakoutscores.close()
- textutils.unserialise(data)
- local breakout = {data}
- print("Breakout:")
- local flappyscores = fs.open("flappyscores","r")
- local data = flappyscores.readAll()
- flappyscores.close()
- textutils.unserialise(data)
- local flappy = {data}
- print("Flappy:")
- local function comp(first,second)
- return first > second
- end
- while true do
- senderId, message, protocol = rednet.receive()
- if protocol == "stacker" and senderId == 144 then
- print("Stacker:")
- table.insert(stacker, message)
- table.sort(stacker, comp)
- local stackerscores = fs.open("stackerscores","w")
- stackerscores.write(table.concat(stacker, '\n'))
- stackerscores.close()
- rednet.send(169, table.concat(stacker,'\n'), "stacker")
- elseif protocol == "breakout" and senderId == 168 then
- print("Breakout:")
- table.insert(breakout, message)
- table.sort(breakout, comp)
- local breakoutscores = fs.open("breakoutscores","w")
- breakoutscores.write(table.concat(breakout, '\n'))
- breakoutscores.close()
- rednet.send(170, table.concat(breakout,'\n'), "breakout")
- elseif protocol == "flappy" and senderId == 168 then
- print("Flappy:")
- table.insert(flappy, message)
- table.sort(flappy, comp)
- local flappyscores = fs.open("flappyscores","w")
- flappyscores.write(table.concat(flappy, '\n'))
- flappyscores.close()
- rednet.send(171, table.concat(flappy,'\n'), "flappy")
- end
- end
Add Comment
Please, Sign In to add comment