Guest User

ff

a guest
Mar 15th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. local sig = os.startTimer(0.05)
  2. while true do
  3.   event,id = os.pullEvent()
  4.   if event == "timer" and id == sig then
  5.     break
  6.   end
  7. end
  8.  
  9. --fast foward
  10.  
  11. local h = fs.open("log","r")
  12. local file = h.readAll()
  13. h.close()
  14.  
  15. --Processing the file
  16. local events = {}
  17.  
  18. for event in file:gmatch("(..-)\n") do
  19.   local first = true
  20.   for word in event:gmatch("(..-);") do
  21.     if first then
  22.       events[#events+1] = {word}
  23.       first = false
  24.     else
  25.       if events[#events][1] == "timer" then
  26.         table.insert(events[#events], tonumber(word)+sig+1)
  27.       else
  28.         table.insert(events[#events],tonumber(word) or word)
  29.       end
  30.     end
  31.   end
  32. end
  33.  
  34. --end processing
  35.  
  36. local yield = coroutine.yield
  37. local resume = coroutine.resume
  38. local oldRaw = os.pullEventRaw
  39. local oldPullEvent = os.pullEvent
  40.  
  41. _ENV.os.pullEventRaw = function(filter)
  42.   if #events == 0 then
  43.     _ENV.os.pullEventRaw = oldRaw
  44.     return oldRaw(filter)
  45.   else
  46.     for i = 1, #events do
  47.       if (events[1][1] == filter) or filter==nil then
  48.         local temp = events[1]
  49.         table.remove(events,1)
  50.         return unpack(temp)
  51.       else
  52.         table.remove(events,1)
  53.       end
  54.     end
  55.     _ENV.os.pullEventRaw = oldRaw
  56.     return oldRaw(filter)
  57.   end
  58. end
  59.  
  60. _ENV.os.pullEvent = function(filter)
  61.   if #events == 0 then
  62.     _ENV.os.pullEvent = oldPullEvent
  63.     return oldPullEvent(filter)
  64.   else
  65.     return _ENV.os.pullEventRaw(filter)
  66.   end
  67. end
Add Comment
Please, Sign In to add comment