3DHTML

I found this script on the wiki and am trying to use it, but I get an error.

[lua]local pos = Vector(-2110.6335449219, -2427.5158691406, -96.081314086914)
local ang = Angle(90, 0, 0)
local width = 1024
local height = 768
local scale = 0.125
local url = “http://google.com

if g_3DHTML and g_3DHTML:IsValid() then g_3DHTML:Remove() end
local browser = vgui.Create(“HTML”)
g_3DHTML = browser
browser:SetPaintedManually(true)
browser:SetSize(width, height)
browser:SetMouseInputEnabled(false)
browser:OpenURL(url)

local function DrawSign()
– Draw a background
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawRect(0, 0, width, height)

    -- Draw the screen
    render.SetMaterial(browser:GetHTMLMaterial())
    render.DrawQuad(Vector(0, 0, 0),
            Vector(width, 0, 0),
            Vector(width, height, 0),
            Vector(0, height, 0))

end

hook.Add(“RenderScreenspaceEffects”, “3DHTMLSign”, function()
cam.Start3D(EyePos(), EyeAngles())
cam.Start3D2D(pos, ang, scale)
local status, err = pcall(DrawSign)
cam.End3D2D()
if not status then Error(err) end
end)[/lua]

Error is: Hook ‘3DHTMLSign’ Failed: [@lua\autorun\client\paint.lua:35] [@lua\autorun\client\paint.lua:23] bad argument #1 to ‘SetMaterial’ (IMaterial expected, got no value)

What is causing this?

You have to wait a frame or 2 since the browser takes a while to initialize, afaik it even was threaded.

I would do an ErrorNoHalt or nothing at all with the error of the pcall, that way it will continue to run the hook even if it errors. This will allow it to wait until it initializes without the use of a timer or something.