Can't figure out how to use resource.AddFile correctly. Noob Question.

Hey I have another simple question that should be really easy but I can’t seem to figure out.

I have icons that I’ve made for an addon that are the correct format. I want to allow them to be displayed in a derma panel, but I can’t figure out how. Everything I’ve tried has returned a little black and pink checker-box .

Here’s the code I have:

serverside:




resource.AddFile("materials/popup/mypopup.vmt")



There’s about 10 of those, only differing in the filename I’m adding. My addon directory looks like this: garrysmod/addons/myaddon/materials/popup

here’s my clientside code:




	local popup = vgui.Create( "DImage", HomePage )
	popup:SetImage( popup/popup_timeout.vmt" )
	popup:SetPos( 165, 170 )
	popup:SizeToContents()



When I pull up the menu, it just has the little pink and black checker board texture. If I put all the files into the gamemodes/terrortown/materials/VGUI/ttt then I don’t need to do a resource.AddFile and it works fine, so I know my files are formatted correctly. However, I would like to be able to add them myself without having to add files to an already existing directory.


popup:SetImage( popup/popup_timeout.vmt" )

You missed an " and you don’t add .vmt in here.

oh that was a typing mistake, the open quote is there in my code. I removed the .vmt and it still is giving me the error material.

Show your .vmt contents.

“UnlitGeneric”
{
“$basetexture” “materials/popup/popup_timeout”
“$vertexcolor” 1
“$vertexalpha” 1
“$translucent” 1
}

“$basetexture” “materials/popup/popup_timeout” -> “$basetexture” “popup/popup_timeout”

Ok so I’m still gettingthe error. I’ll post all of my code again, with the fixes you guys have suggested.

clientside:




	local popup = vgui.Create( "DImage", HomePage )
	popup:SetImage( "materials/popup/popup_timeout" )
	popup:SetPos( 165, 170 )
	popup:SizeToContents()



serverside:




resource.AddFile("materials/popup/popup_timeout.vmt")



VMT file:




"UnlitGeneric"
{
 "$basetexture" "popup/popup_timeout"
 "$vertexcolor" 1
 "$vertexalpha" 1
 "$translucent" 1
}



and my directory goes like this:

addons/myaddon/materials/popup

popup:SetImage( “popup/popup_timeout” )

That worked! thank you so much robotboy and handsome matt!