I'm stuck with this expected to close near error

‘}’ expected (to close ‘{’ at line 73) near text_spacing

it says at line 73 but as far as I know it is closed, please bear with me as I’m pretty much new to Lua

[lua]good_hud = { };

local function clr( color ) return color.r, color.g, color.b, color.a; end

function good_hud:PaintBar (x, y, w, h, colors, value )

self:PaintPanel(x, y, w, h, colors )

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );

local width = w * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );

surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect ( x, y + shade, width, h - shade );

end

local Colors =
{
border = Color( 255, 255, 255, 255),
background = Color( 255, 255, 255, 200 ),
shade = Color( 255, 255, 255, 255 ),
fill = Color( 0, 0, 0, 255 ),
};

good_hud:PaintBar( 50, 50, 250, 16, colors, 0.75 );

function good_hud:PaintPanel (x, y, w, h, colors )

surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );

end

function good_hud:PaintText( x, y, text, font, colors )
surface.SetFont( font );

surface.SetTextPos( x + 1, y + 1);
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );

end

local colors =
{
    shdow = Color( 0, 0, 0, 155 ),
    text = Color(255, 255, 255, 255 )
    
};

good_hud:PaintText( 50,50, "Health", "Armor", colors );

function good_hud:TextSize( text, font )

    surface.SetFont( font );
    return surface.GetTextSize( text );
    
end

local vars =
{
    font = "TargetID",
    
    padding = 10,
    margin = 35
    
    text_spacing = 2,
    bar_spacing = 5,
    
    bar_height = 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 )
    },
    
    health_bar =
    {
    border = Color( 255, 0, 0, 255 ),
    background = Color( 255, 0, 0, 75 ),
    shade = Color( 255, 104, 104, 255 ),
    fill = Color( 232, 0, 0, 255 )
    
    },
    
    suit_bar =
    {
        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 HUDPaint( )
client = client or LocalPlayer( );
if( !client:Alive( ) ) then return; end

local _, th = good_hud:TextSize( "TEXT", vars.font );

local i = 2;

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

local x = vars.margin;
local y = ScrH( ) - vars.margin - height;

local cx = x + vars.padding;
local cy = y + vars.padding;

good_hud:PaintPanel( x, y, width, height, colors.background );

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

local text = string.format( "Health: %iHP", 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( "Suit: %iSP", 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]

[editline]7th February 2012[/editline]

Use LUA box Please.

[lua]
good_hud = { };

local function clr( color ) return color.r, color.g, color.b, color.a; end

function good_hud:PaintBar (x, y, w, h, colors, value )

self:PaintPanel(x, y, w, h, colors )

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );

local width = w * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );

surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect ( x, y + shade, width, h - shade );

end

local Colors =
{
border = Color( 255, 255, 255, 255),
background = Color( 255, 255, 255, 200 ),
shade = Color( 255, 255, 255, 255 ),
fill = Color( 0, 0, 0, 255 ),
};

good_hud:PaintBar( 50, 50, 250, 16, colors, 0.75 );

function good_hud:paintPanel (x, y, w, h, colors )

surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );

end

function good_hud:PaintText( x, y, text, font, colors )
surface.SetFont( font );

surface.SetTextPos( x + 1, y + 1);
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );

end

local colors =
{
    shdow = Color( 0, 0, 0, 155 ),
    text = Color(255, 255, 255, 255 )
    
};

good_hud:PaintText( 50,50, "Health", "Armor", colors );

function good_hud:TextSize( text, font )

    surface.SetFont( font );
    return surface.GetTextSize( text );
    
end

local vars =
{
    font = "TargetID",
    
    padding = 10,
    margin = 35
    
    text_spacing = 2,
    bar_spacing = 5,
    
    bar_height = 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 )
    },
    
    health_bar =
    {
    border = Color( 255, 0, 0, 255 ),
    background = Color( 255, 0, 0, 75 ),
    shade = Color( 255, 104, 104, 255 ),
    fill = Color( 232, 0, 0, 255 )
    
    },
    
    suit_bar =
    {
        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 HUDPaint( )
client = client or LocalPlayer( );
if( !client:Alive( ) ) then return; end

local _, th = good_hud:TextSize( "TEXT", vars.font );

local i = 2;

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

local x = vars.margin;
local y = ScrH( ) - vars.margin - height;

local cx = x + vars.padding;
local cy = y + vars.padding;

good_hud:PaintPanel( x, y, width, height, colors.background );

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

local text = string.format( "Health: %iHP", 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( "Suit: %iSP", 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]

Also, your missing a comma after margin = 35

[lua]
good_hud = { };

local function clr( color ) return color.r, color.g, color.b, color.a; end

function good_hud:PaintBar (x, y, w, h, colors, value )

self:PaintPanel(x, y, w, h, colors )

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );

local width = w * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );

surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect ( x, y + shade, width, h - shade );

end

local Colors =
{
border = Color( 255, 255, 255, 255),
background = Color( 255, 255, 255, 200 ),
shade = Color( 255, 255, 255, 255 ),
fill = Color( 0, 0, 0, 255 ),
};

good_hud:PaintBar( 50, 50, 250, 16, colors, 0.75 );

function good_hud:paintPanel (x, y, w, h, colors )

surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );

end

function good_hud:PaintText( x, y, text, font, colors )
surface.SetFont( font );

surface.SetTextPos( x + 1, y + 1);
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );

end

local colors =
{
    shdow = Color( 0, 0, 0, 155 ),
    text = Color(255, 255, 255, 255 )
    
};

good_hud:PaintText( 50,50, "Health", "Armor", colors );

function good_hud:TextSize( text, font )

    surface.SetFont( font );
    return surface.GetTextSize( text );
    
end

local vars =
{
    font = "TargetID",
    
    padding = 10,
    margin = 35, --Missed a comma.
    
    text_spacing = 2,
    bar_spacing = 5,
    
    bar_height = 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 )
    },
    
    health_bar =
    {
    border = Color( 255, 0, 0, 255 ),
    background = Color( 255, 0, 0, 75 ),
    shade = Color( 255, 104, 104, 255 ),
    fill = Color( 232, 0, 0, 255 )
    
    },
    
    suit_bar =
    {
        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 HUDPaint( )
client = client or LocalPlayer( );
if( !client:Alive( ) ) then return; end

local _, th = good_hud:TextSize( "TEXT", vars.font );

local i = 2;

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

local x = vars.margin;
local y = ScrH( ) - vars.margin - height;

local cx = x + vars.padding;
local cy = y + vars.padding;

good_hud:PaintPanel( x, y, width, height, colors.background );

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

local text = string.format( "Health: %iHP", 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( "Suit: %iSP", 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]

Quick question, what was the point of the redundant function, clr()?

i learned it from a tutorial but the tutorial sucks because PaintPanel seems to not work

[editline]8th February 2012[/editline]

I’m a beginner at this stuff so to be honest what would be the correct function then

[editline]8th February 2012[/editline]

I fixed that error but its now telling me that my PaintPanel is a nil value. I’m so confused right now

That’s because you defined the function as “paintPanel” instead of “PaintPanel”. Probably. “function good_hud:paintPanel (x, y, w, h, colors )”

I actually fixed that forgot to update the code but the error still remains, ugh this is a pain in my ass

Also, there’s not supposed to be a space between the function name and the parenthesis directly after it containing the arguments. You probably fixed that too though, so I’m not sure what else it might be… Right now I don’t feel like inspecting ALL of that code, and I’m not good with HUD to begin with ^^’ you’re not getting any other errors? While starting the game?

no it’s just that PaintPanel error, if I do get any other errors I’ll be sure to post it. I learn by what I’m told or by observing.

[editline]9th February 2012[/editline]

heres what I get when when in gmod
[lua\autorun\client\hud.lua:7] attempt to call method ‘PaintPanel’ (a nil value)
E

What does hud.lua look like? Specifically the chunk that has that line. Maybe you’re calling the method on an object that doesn’t have it. Unfortunately I haven’t looked into how to make methods properly, or classes that use them for that matter… I’m going to but it might take a while so you’ll probably want someone elses help if that’s the case. For now, post the chunk of code containing line 7 of hud.lua. I assume that’s not the same code as what you’ve posted here, because here line 7 is empty.

[lua]good_hud = { };

local function clr( color ) return color.r, color.g, color.b, color.a; end

function good_hud:PaintBar(x, y, w, h, colors, value )

self:PaintPanel(x, y, w, h, colors );

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

local width = w * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );

surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect ( x, y + shade, width, h - shade );

end[/lua]

[editline]9th February 2012[/editline]

as you can see everything seems right but you may have a good hunch on the object thing

Yeah, I honestly have no clue about what could be wrong, it looks right to me :confused: Sorry.

It’s alright I appreciate the attempt to help me

Where is good_hud:PaintPanel() defined?

good question that might be the reason its giving me grief lol

[editline]10th February 2012[/editline]

ok fixed that issue, only thing left to do now is define colors heh quite the learning curveball for me