Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sig = os.startTimer(0.05)
- while true do
- event,id = os.pullEvent()
- if event == "timer" and id == sig then
- break
- end
- end
- --fast foward
- local h = fs.open("log","r")
- local file = h.readAll()
- h.close()
- --Processing the file
- local events = {}
- for event in file:gmatch("(..-)\n") do
- local first = true
- for word in event:gmatch("(..-);") do
- if first then
- events[#events+1] = {word}
- first = false
- else
- if events[#events][1] == "timer" then
- table.insert(events[#events], tonumber(word)+sig+1)
- else
- table.insert(events[#events],tonumber(word) or word)
- end
- end
- end
- end
- --end processing
- local yield = coroutine.yield
- local resume = coroutine.resume
- local oldRaw = os.pullEventRaw
- local oldPullEvent = os.pullEvent
- _ENV.os.pullEventRaw = function(filter)
- if #events == 0 then
- _ENV.os.pullEventRaw = oldRaw
- return oldRaw(filter)
- else
- for i = 1, #events do
- if (events[1][1] == filter) or filter==nil then
- local temp = events[1]
- table.remove(events,1)
- return unpack(temp)
- else
- table.remove(events,1)
- end
- end
- _ENV.os.pullEventRaw = oldRaw
- return oldRaw(filter)
- end
- end
- _ENV.os.pullEvent = function(filter)
- if #events == 0 then
- _ENV.os.pullEvent = oldPullEvent
- return oldPullEvent(filter)
- else
- return _ENV.os.pullEventRaw(filter)
- end
- end
Add Comment
Please, Sign In to add comment