CapsAdmin

Untitled

May 26th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. if _G.SIGH and _G.SIGH:IsValid() then _G.SIGH:Remove() end
  2.  
  3. local pnl = vgui.Create("DHTML")
  4. pnl:SetHTML("")
  5. pnl:AddFunction("lua", "print", function(text)
  6.     chat.AddText(text)
  7. end)
  8.  
  9. local data = {}
  10. local i = 0
  11. for char in OGG_DATA:gmatch("(.)") do
  12.     table.insert(data, ("b[%u]=%i;"):format(i, char:byte()))
  13.     i = i + 1
  14. end
  15. data = table.concat(data, "")
  16. print(data:sub(1, 1000))
  17.  
  18. pnl:RunJavascript(([[
  19.     b = new ArrayBuffer(%s)
  20.        
  21.     %s
  22.        
  23.     audio = new webkitAudioContext
  24.     audio.decodeAudioData(
  25.         b,
  26.  
  27.         function(buffer)
  28.         {
  29.             lua.print("wooo")
  30.         },
  31.  
  32.         function(err)
  33.         {
  34.             lua.print("decoding error " + err)
  35.         }
  36.     )
  37. ]]):format(#OGG_DATA, data))
  38.  
  39. --[===[
  40.  
  41. file.Write("test.txt", "LOLOLOL")
  42. local function decode(data)
  43.     pnl:RunJavascript(([[
  44.         function str2ab(str) {
  45.             var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
  46.             var bufView = new Uint16Array(buf);
  47.                
  48.             for (var i=0, strLen=str.length; i<strLen; i++)
  49.             {
  50.                 bufView[i] = str.charCodeAt(i);
  51.             }
  52.             return buf;
  53.         }
  54.                
  55.         audio = new webkitAudioContext
  56.         var data = str2ab("%s")
  57.         lua.print(data.toString())
  58.  
  59.         audio.decodeAudioData(
  60.             data,
  61.    
  62.             function(buffer)
  63.             {
  64.                 lua.print("wooo")
  65.             },
  66.    
  67.             function(err)
  68.             {
  69.                 lua.print("decoding error " + err)
  70.             }
  71.         )
  72.     ]]):format(data))
  73. end
  74.  
  75. if OGG_DATA then
  76.     decode(OGG_DATA)   
  77. else
  78.     http.Fetch("http://raw.github.com/CapsAdmin/pac3/master/about/music.ogg", function(data)
  79.         decode(data)
  80.         OGG_DATA = data
  81.     end)
  82. end
  83. ]===]
  84.  
  85. _G.SIGH = pnl
Advertisement
Add Comment
Please, Sign In to add comment