Hud not showing up

I don’t get any errors at all, but this code still doesn’t seem to work:
[lua]
local function good_hud( )

client = client or LocalPlayer( );				-- set a shortcut to the client
if( !client:Alive( ) ) then return; end				-- don't draw if the client is dead

local _, th = good_hud:TextSize( "TEXT", vars.font );		-- get text size( height in this case )

local i = 2;							-- shortcut to how many items( bars + text ) we have

local width = vars.width * ScrW( );				-- calculate width
local bar_width = width - ( vars.padding * i );			-- calculate bar width and element height
local height = ( vars.padding * i ) + ( th * i ) + ( vars.text_spacing * i ) + ( vars.bar_height * i ) + vars.bar_spacing;

local x = vars.margin;						-- get x position of element
local y = ScrH( ) - vars.margin - height;			-- get y position of element

local cx = x + vars.padding;					-- get x and y of contents
local cy = y + vars.padding;

good_hud:PaintPanel( x, y, width, height, colors.background );	-- paint the background panel

local by = th + vars.text_spacing;				-- calc text position

local text = string.format( "Health: ", client:Health( ) );	-- get health text
good_hud:PaintText( cx, cy, text, vars.font, colors.text );	-- paint health text and health bar
good_hud:PaintBar( cx, cy + by, bar_width, vars.bar_height, colors.health_bar, client:Health( ) / 100 );

by = by + vars.bar_height + vars.bar_spacing;			-- increment text position

local text = string.format( "Armor: ", client:Armor( ) );	-- get suit text
good_hud:PaintText( cx, cy + by, text, vars.font, colors.text );	-- paint suit text and suit bar
good_hud:PaintBar( cx, cy + by + th + vars.text_spacing, bar_width, vars.bar_height, colors.suit_bar, client:Armor( ) / 100 );

end

hook.Add( “HUDPaint”, “PaintOurHud”, HUDPaint );
[/lua]
All of the variables are defined earlier in the code, I’m just posting the part where the HUD painting takes place.

Can somebody tell me what I’m missing?

The [lua]hook.Add( “HUDPaint”, “PaintOurHud”, HUDPaint );[/lua] should be [lua]hook.Add( “HUDPaint”, “PaintOurHud”, good_hud );[/lua]

Well that fixed the HUD not being called, but now I get:

Hook ‘PaintOurHud’ Failed: geoforts\gamemode\cl_healtharmor.lua:70: attempt to index upvalue ‘good_hud’ (a function value)

You have a function and a table with the same name.

That solved it, but now I have yet another error…

I get:

geoforts\gamemode\cl_healtharmor.lua:13: ‘}’ expected (to close ‘{’ at line 11) near ‘textsize’

Here’s my whole code:
[lua]
function hidehud(name)
for k, v in pairs{“CHudHealth”, “CHudBattery”} do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

goodhud = { }

local vars =
{
font = “TargetID”
textsize = 8
padding = 10
margin = 35
textspacing = 2
barspacing = 5
barheight = 16
width = 0.25
};

local colors =
{
background =
{

	border = Color( 190, 255, 128, 255 ),
	background = Color( 120, 240, 0, 75 )

},

text =
{

	shadow = Color( 0, 0, 0, 200 ),
	text = Color( 255, 255, 255, 255 )

},

healthbar =
{

	border = Color( 255, 0, 0, 255 ),
	background = Color( 255, 0, 0, 75 ),
	shade = Color( 255, 104, 104, 255 ),
	fill = Color( 232, 0, 0, 255 )

},

suitbar =
{

	border = Color( 0, 0, 255, 255 ),
	background = Color( 0, 0, 255, 75 ),
	shade = Color( 136, 136, 255, 255 ),
	fill = Color( 0, 0, 219, 255 )

}

};

local function drawmyhud( )

client = client or LocalPlayer( );				-- set a shortcut to the client
if( !client:Alive( ) ) then return; end				-- don't draw if the client is dead

local _, th = goodhud:TextSize( "TEXT", vars.textsize );		-- get text size( height in this case )

local i = 2;							-- shortcut to how many items( bars + text ) we have

local width = vars.width * ScrW( );				-- calculate width
local barwidth = width - ( vars.padding * i );			-- calculate bar width and element height
local height = ( vars.padding * i ) + ( th * i ) + ( vars.textspacing * i ) + ( vars.barheight * i ) + vars.barspacing;

local x = vars.margin;						-- get x position of element
local y = ScrH( ) - vars.margin - height;			-- get y position of element

local cx = x + vars.padding;					-- get x and y of contents
local cy = y + vars.padding;

goodhud:PaintPanel( x, y, width, height, colors.background );	-- paint the background panel

local by = th + vars.textspacing;				-- calc text position

local text = string.format( "Health: ", client:Health( ) );	-- get health text
goodhud:PaintText( cx, cy, text, vars.font, colors.text );	-- paint health text and health bar
goodhud:PaintBar( cx, cy + by, barwidth, vars.barheight, colors.healthbar, client:Health( ) / 100 );

by = by + vars.barheight + vars.barspacing;			-- increment text position

local text = string.format( "Armor: ", client:Armor( ) );	-- get suit text
goodhud:PaintText( cx, cy + by, text, vars.font, colors.text );	-- paint suit text and suit bar
goodhud:PaintBar( cx, cy + by + th + vars.textspacing, barwidth, vars.barheight, colors.suitbar, client:Armor( ) / 100 );

end

hook.Add( “HUDPaint”, “PaintOurHud”, drawmyhud );
[/lua]
It doesn’t make sense, there isn’t any ‘}’ at line 13…

You need to seperate each field in your table with a comma.

[lua]local vars =
{
font = “TargetID”,
textsize = 8,
padding = 10,
margin = 35,
textspacing = 2,
barspacing = 5,
barheight = 16,
width = 0.25
}; [/lua]

:doh:
I missed a comma on ‘textsize’, and I thought the commas were a problem.
Thanks!

[editline]01:10PM[/editline]

:sigh:

Now I get:

Hook ‘PaintOurHud’ Failed: geoforts\gamemode\cl_healtharmor.lua:67: attempt to call method ‘TextSize’ (a nil value)

bump

You need to tell TextSize to stop being a nil value! Duh!

[editline]08:12PM[/editline]

XD

You are trying to call a method on goodhud that doesn’t exist. The tutorial that you got that code from shows you how to define the method.