Few simple questions

Im just gonna go straight to it:

What ways are there to add png images to derma I have my images located
(I did it before but can’t remember how :// )


addonname/materials/addonname/

Im not sure how to add them in and make sure the client downloads them. Ive seen resource.AddFile and something to do with it but there aren’t many examples.
Also I have sounds


addonname/sound/addonname/

can i just use


button.DoClick = function()
     surface.PlaySound( "addonname/sound.wav" )
end


Thanks in advance

I believe that you can use images as materials by calling the Material function with a path relative to /materials/
[lua]local img = Material( “addonname/image.png”, “noclamp smooth” )[/lua]
The second parameter is arguments which affect the way the image is loaded, these make the image look better.
You can then draw it using a function such as draw.TexturedQuad.
resource.AddFile can be used to make clients download any file relative to the /garrysmod/ folder of your server, all addons folders are linked up, so if your file resided in garrysmod/addon/addonname/materials/addonname/image.png you’d simply call
[lua]resource.AddFile( “materials/image.png” )[/lua]
The same applies to all subfolders of your addon folder.
If you have successfully added your sounds to the resource list then your surface.PlaySound should work correctly.

Ok i understand this but how can I parent it to a DFrame like a DImage except im sure the DImage uses the .vmt format so I dont want to use .vmt.

Well you could just use any old derma control (DImage, I suppose) and just override the Paint function to draw the image in its place
[lua]local img = base:Add( “DImage” )
img.Paint = function( self, w, h )

draw.TexturedQuad( {
	material = surface.GetTextureID( "myaddon/image.png" ),
	color = Color( 255, 255, 255 ),
	x = 0,
	y = 0,
	w = w,
	h = h
} )

end[/lua]



[ERROR] addons/test_menu/lua/autorun/client/cl_menu.lua:45: attempt to index global 'base' (a nil value)
  1. unknown - addons/test_menu/lua/autorun/client/cl_menu.lua:45


Sorry for being annoying man, learning I guess…



local img = base:Add( "DImage" )
img.Paint = function( self, w, h )

	draw.TexturedQuad( {
		material = surface.GetTextureID( "testmenuimages/user.png" ),
		color = Color( 255, 255, 255 ),
		x = 0,
		y = 0,
		w = w,
		h = h
	} )

end



I meant for you to replace base with the DFrame (or other derma element you are using as a base). The method Add() creates a new derma element and automatically sets its parent to the element which you ran the method on.