Python1320

wtf procrastination

Oct 5th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. dc_joinlog=dc_joinlog or file.Read("logs/dc_joinlog.txt")
  2. local ptr=1-13
  3. local d=dc_joinlog
  4. local len=#d
  5. res={}
  6.  
  7. local EVENT_JOINTIME=1
  8. local EVENT_DISCTIME=2
  9.  
  10. local byte,char=string.byte,string.char  
  11.  
  12. local function proc(str)
  13.     local date,event,value,uid=from_u_int(str),byte(str[5]),from_u_int(str,nil,5),from_u_int(str,nil,5+4)
  14.     --Msg"[Log] "print( Format("At %s by %s: %s Time: %s",
  15.     table.insert(res,{
  16.     os.date("%c",date),
  17.     uid,
  18.     event==EVENT_JOINTIME and "join"
  19.     or event==EVENT_DISCTIME and "leave"
  20.     or event,
  21.     os.prettydate(value)
  22.     }
  23.     )
  24.    
  25.     --)
  26.    
  27. end
  28.  
  29.  
  30.  
  31.  
  32. while ptr<len-13 do
  33.         ptr=ptr+13 -- next offset
  34.         proc(d:sub(ptr,ptr+13-1))
  35. end
  36.  
  37.  
  38. local events={}
  39. for k,v in pairs(res) do
  40.     events[v[2]]=events[v[2]] and events[v[2]] + 1 or 1
  41. end
  42. events2={}
  43. for k,v in pairs(events) do
  44.    table.insert(events2,{k,v})
  45. end
  46.  
  47.  
  48. if res2 then
  49.  
  50. table.sort(events2,function(a,b) return a[2]>b[2] end)
  51. for i=1,10 do
  52.     local res=res2[events2[i][1]]
  53.    print(res and res.name or events2[i][1],events2[i][2] .. " events")
  54. end
  55.  
  56.  return end
  57.  
  58. local files=file.Find("dcraft/*")
  59. local i=#files+1
  60. res2={}
  61. local function proc()
  62.     i=i-1
  63.     local name=files[i]
  64.     if not name then timer.Remove("LAG") print("FINITO after "..#files) return end
  65.     local data=glon.decode(file.Read("dcraft/"..name))
  66.     if not data then print("wat",name) error"derped" end
  67.     res2[tonumber(data.uid)]=data
  68.     Msg(i)
  69. end
  70.  
  71. timer.Create('LAG',0,0,function()
  72.     for i=0,10 do proc() end
  73. end)
  74.  
Advertisement
Add Comment
Please, Sign In to add comment