Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get j9qGCdRR syncro
- local path = "disk/disknet_data"
- local eventBlacklist = {
- timer = true,
- }
- local id = math.random(0,99999999) --this might be replaced with a better check
- local wfile = fs.open(path,"a")
- wfile.flush()
- local rfile = fs.open(path,"r")
- local readData = function()
- local line, tblpos
- while true do
- line = rfile.readLine()
- if line then
- if line:sub(1,#tostring(id)) ~= tostring(id) then
- tblpos = line:find("{")
- detectedEvents = textutils.unserialize(line:sub(tblpos+1))
- os.queueEvent(table.unpack(detectedEvents))
- for a = 1, #detectedEvents do
- print(detectedEvents[a])
- end
- term.setBackgroundColor(colors.white)
- term.clearLine()
- term.setBackgroundColor(colors.black)
- print("")
- end
- else
- sleep(0)
- end
- end
- end
- local writeData = function()
- local evt
- while true do
- evt = {os.pullEvent()}
- if not eventBlacklist[evt[1]] then
- wfile.writeLine(tostring(id)..textutils.serialize(evt):gsub("\n",""):gsub(",}","}"))
- wfile.flush()
- end
- end
- end
- parallel.waitForAny(writeData,readData)
Add Comment
Please, Sign In to add comment