Python1320

failblog

May 12th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 KB | None | 0 0
  1. if SERVER then
  2.     local function XMLToTable(xml)
  3.         if !gxml then require'gxml' end
  4.         if !gxml then error'no gxml found!' end
  5.  
  6.         local h = gxml.simpleTreeHandler()
  7.         local x = gxml.xmlParser(h)
  8.         x:parse(xml)
  9.         return h.root
  10.     end
  11.  
  12.  
  13.     http.Get([[http://feeds.feedburner.com/failblog]],'',function(a,b)
  14.         XML=XMLToTable(a)
  15.         for num,xml in RandomPairs(XML.rss.channel.item) do
  16.             local content=xml['media:content']
  17.             content=content and content[2]
  18.             content=content and content._attr
  19.             content=content and content.url
  20.             if content then
  21.                 umsg.Start('LOL')
  22.                     umsg.String(content)
  23.                 umsg.End()
  24.                 return
  25.             end
  26.         end
  27.        
  28.     end)
  29.     return
  30. end
  31.  
  32. usermessage.Hook('LOL',function(umsg)
  33.     local content=tostring(umsg:ReadString())
  34.     if content then
  35.         local HTML=[[
  36.         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
  37.        
  38.     <style type="text/css">
  39.         body { padding: 0; margin: 0; }
  40.     </style>
  41.     <body>
  42.         <img src="]]..content..[[" height="1024" width="1024" />
  43.     </body>
  44.     </html>]]
  45.         Browser:SetHTML(HTML)
  46.     end
  47. end)
  48.  
  49. local ENT=Entity(339)
  50.     ENT.Width   =   1024
  51.     ENT.Height  =1024
  52.     ENT.Scale   =   0.2
  53. local vector_origin=vector_origin
  54. function ENT:Draw3D2D(wide,tall)
  55.     if not self.BrowserMat then return end
  56.  
  57.     render.SetMaterial(self.BrowserMat)
  58.     local x,y=self.Width*2,self.Height*2
  59.     render.DrawQuad(
  60.         Vector(x,y,0),
  61.         Vector(x+self.Width, y, 0),
  62.         Vector(x+self.Width, y+self.Height, 0),
  63.         Vector(x, self.Height+y, 0))
  64.        
  65.     --[[ Ugh, draw order :(. Let's use 3d2d then.
  66.     local r=self:GetRight()
  67.     local u=self:GetUp()
  68.     local f=self:GetForward()
  69.     local wide=self.Width
  70.     local tall=self.Height
  71.     local p=self:GetPos()+u*tall/2+r*((wide/2))
  72.     render.DrawQuad(
  73.         p,
  74.         p-r*wide,
  75.         p-r*wide-u*tall,
  76.         p-u*tall)--]]
  77.        
  78.     --[[
  79.    
  80.         22:52 - Python132O: Don't draw them in 3d2d (HUGE leak) <- Does that also apply if you're using 3d2d and do render.DrawQuad with the html material?
  81.         22:53 - AzuiSleet: "Also, does anyone know why a large number of Lua MD5 mismatches occur (Even with default addons removed)"
  82.         22:53 - AzuiSleet: "using 3d2d and do render.DrawQuad with the html materia"
  83.         AzuiSleet is now Offline.
  84.     ]]
  85.    
  86. end
  87.  
  88. function ENT:OnThink()
  89.     self.BrowserMat = Browser and Browser:GetHTMLMaterial()  
  90.    
  91.     self:NextThink(CurTime() + 1)  
  92. end  
  93.  
  94.  
  95.  
  96. if Browser and Browser:IsValid() then
  97.     Browser:Remove()
  98. end
  99. Browser = vgui.Create("HTML")
  100. Browser:SetMouseInputEnabled(false)        
  101. Browser:SetSize(1024, 1024)
  102. Browser:SetPaintedManually(true)
  103. Browser:SetVerticalScrollbarEnabled(false)
  104. Browser:OpenURL[[http://google.fi]]
Advertisement
Add Comment
Please, Sign In to add comment