Hey everybody.
I'm new to programming so forgive me please. I was wondering how I can change the HUD health object from a rounded square as it was programmed, to an actual image?
Thanks!
-SlamageDeluxe
A mix of:
[url]http://wiki.garrysmod.com/page/Global/Material[/url]
[url]http://wiki.garrysmod.com/page/surface/SetMaterial[/url]
[url]http://wiki.garrysmod.com/page/surface/DrawTexturedRect[/url]
Also make sure not to call Material within a hook, define it outside of one before you start to use it.
Or you can check if that value is nil before using it, and if it is; then define it.
Method 1:
[lua]
local mIcon = Material( "icon16/accept.png" );
hook.Add( "HUDPaint", "MyPaintThingy", function( )
surface.SetMaterial( mIcon );
surface.DrawTexturedRect( 16, ScrH() / 2, 16, 16 );
end );[/lua]
Method 2:
[lua]
local mIcon;
hook.Add( "HUDPaint", "MyPaintThingy", function( )
if ( !mIcon ) then
mIcon = Material( "icon16/accept.png" );
end
surface.SetMaterial( mIcon );
surface.DrawTexturedRect( 16, ScrH() / 2, 16, 16 );
end );[/lua]
Whatever floats your boat honestly.
[B]Oh, and here's how to do it wrong:[/B]
[lua]hook.Add( "HUDPaint", "LOOK MOM, I CAN DO IT WRONG!", function( )
surface.SetMaterial( Material( "icon16/accept.png" ) );
surface.DrawTexturedRect( 16, ScrH() / 2 );
end );[/lua]
Why is this tagged as C++?
Sorry, you need to Log In to post a reply to this thread.