Adding a png to HUDPaint

I am working on a hud, and I am having a hard time making a png I made in gimp to display on the hud paint.

Here is my file structure for the addon


HUD -> - lua -> autorun -> hud.lua
       - materials -> untitled.png
       - resource -> fonts -> - font1.ttf
	                      - font2.ttf
	   		      - font3.ttf

Here is the code trying to access the png in the addon… Could I possibly have my file structure wrong?


if SERVER then
	resource.AddFile("materials/untitled.png")
end

local infoFill = Material("materials/untitled.png")

hook.add("HUDPaint", "hud" function(

    surface.SetMaterial(infoFill)
    surface.DrawTexturedRect(x+260,y+height-100,60,80)

end))

I’ve been trying to figure this out for awhile, any ideas?

Read.

Yeah… I’ve read it many times before, it doesn’t explain how to add png files that aren’t already incluced in the GMod files, not to mention I’m testing on a local server so there is no Garrysmod/garrysmod/materials folder.

Read. The. Page. Don’t assume. Do not skim it. READ IT. PLEASE.

Am I asking too much?

Look at the examples. Read them. Compare them to your code.

Your hook is all over the place. You did a lowercase ‘A’, the whole code is inside the bit you’re supposed to put arguments in and you forgot to do surface.SetDrawColor( 255, 255, 255 ) to make sure it’s white

You need to READ my reply saying I have READ the page MULTIPLE times.

Like I said, the page is talking about the Garrysmod/garrysmod/materials folder in the GMOD game files, not SERVER files or an ADDON file. Now please, if you aren’t going to say anything helpful PLEASE do not reply.

No guarantees this will work but:



if SERVER then
	resource.AddFile("untitled.png")
end

local infoFill = Material("untitled.png")

hook.Add("HUDPaint", "hud", function()
    surface.SetDrawColor( 255, 255, 255, 255 )
    surface.SetMaterial(infoFill)
    surface.DrawTexturedRect(x+260,y+height-100,60,80)
end)


In my lua code it’s correct, I just wrote the example here because I didn’t want to copy and paste anything from my file.

I think what he meant is that if you read the page you can kinda tell you’re not supposed to have materials/ in your material path.

Addon folders and the game’s folders are virtually combined, so any material in addons/HUD/materials will be seen as also being inside the garrysmod/materials folder.

I’ve tried that, hasn’t worked.

What about the thing I posted before

WOW…

Simply adding the surface.SetDrawColor() before setting the texture has fixed it. I can’t believe it was that simple.