Hiya expert lua coders,
I'm having difficulty with getting my DImage to work on my derma panel; I have tried lots of different things i have found on the internet such as using a .png instead of a .vmt, .vtf but that didnt work. Also tried forcing the user to download the image upon connecting to the server (which works) but it still doesn't display.
This is the code i am using; if you need any other things then please just ask:
[CODE]
function medals:DoDoubleClick( lineID , line )
if ( lineID == 1 ) then
medalpanel = vgui.Create( "DPanel", awardmenu )
medalpanel:SetPos( 400 , 100 )
medalpanel:SetSize( 600 , 600 )
medalimg = vgui.Create( "DImage", medalpanel )
medalimg:SetPos( 0 , 0 )
medalimg:SetSize( 600 , 600 )
medalimg:SetImage( "medals/medal_4.png" )
end
[/CODE]
The png image is saved into garrysmod/materials/medals/<file name> which i've been told is the right path. Although I had to create the materials folder in the garrysmod/ directory... due to it for some reason not being there in the first place. Would this affect it or do i need to save the image somewhere else or something?
You need to add the extension onto the end of the path to the file. e.g. ".png" ".vtf"
[QUOTE=Promptitude;52083750]You need to add the extension onto the end of the path to the file. e.g. ".png" ".vtf"[/QUOTE]
I have tried this as well for .png when i tried using that, and i have tried .vmt and .vtf on the end of the files; still no effect, the image still appears black and purple
First of all you are using incorrect material shader for HUD/GUI/UI, you should be using "UnlitGeneric",
secondly your $basetexture is all wrong, get rid of "garrysmod/materials/" and the ".vtf".
[QUOTE=Robotboy655;52083819]First of all you are using incorrect material shader for HUD/GUI/UI, you should be using "UnlitGeneric",
secondly your $basetexture is all wrong, get rid of "garrysmod/materials/" and the ".vtf".[/QUOTE]
Hiya RobotBoy (big fan btw), i will fix the $basetexture field, but i dont quite understand what you mean about the HUD/GUI/UI? would you be able to explain a little more?
EDIT:
I have changed the "LightmappedGeneric" to "UnlitGeneric"; as i believed thats what you meant. However, I still am just getting a flickering purple and black image
The first line of the vmt is the shader to be used by the material, LightmappedGeneric is for map brushes, "UnlitGeneric" is for stuff you want to use it - display simple textures on screen without lighting information from the map being taken into account.
Okay thank you, my .vmt file now looks like this:
[CODE]
"UnlitGeneric"
{
"$basetexture" "medals/medal_1"
"$translucent" 0
}
[/CODE]
However, I am still getting a flickering black and purple image when i load up the dframe...
Either you did not update it properly ( i.e. the old file is still somewhere, like download/ folder or addons ) or the .vtf file ( the actual texture ) doesnt exist in materials/medals/ by the name medal_1
I have my .vtf and .vmt files all in the /materials/medals/.. folder, they are both called medal_1.vtf and medal_1.vmt; would it be because i moved the vtf file after i had converted it from .png? But i did change the $basetexture on the .vmt file and can't find any file directories that i could potentially have to change in the .vtf file... so i don't believe it would be this
I definitely have updated it and have made sure that it is the correct files and they are not in the download files.
[editline]10th April 2017[/editline]
This is all the code if it helps, i'm wanting the image to appear when a certain line is double clicked in the DListView (medals)... i've left most of the other elements blank at the moment as i am trying to sort out this DImage
[CODE]
function medals:DoDoubleClick( lineID , line )
if ( lineID == 1 ) then
local medalimg = vgui.Create( "DImage", awardmenu )
medalimg:SetPos( 400 , 100 )
medalimg:SetSize( 600 , 600 )
medalimg:SetImage( 'medals/medal_1' )
local medaldesc = vgui.Create( "DLabel", awardmenu )
local awardButton = vgui.Create( "DButton", awardmenu )
end
if (lineID == 2) then
local medalimg = vgui.Create( "DImage", awardmenu )
medalimg:SetPos( 400 , 100 )
medalimg:SetSize( 600 , 600 )
medalimg:SetImage( 'medals/medal_2' )
local medaldesc = vgui.Create( "DLabel", awardmenu )
local awardButton = vgui.Create( "DButton", awardmenu )
end
end
[/CODE]
Anyone any ideas? xD cos i'm really stuck haha
[editline]10th April 2017[/editline]
[url]https://gyazo.com/8ca55d5267c1e3390334d85162e3d123?token=035679f4f681126828c83a2540a01cc3[/url]
This is a screenshot of what appears on my screen, the reason it has a black stripe in the middle is due to the flickering of the DImage
Yeah the vmt is not updated.
[QUOTE=Robotboy655;52085077]Yeah the vmt is not updated.[/QUOTE]
I have been updating it over and over, with the new data and putting it back into the garrysmod/materials/medals/.. folder with its assosciated .vtf file. I have even gone as far as deleting them both and changing the .png to .vtf and .vmt again then changing the shader and $basetexture then uploading them again... but still no luck :/
Wait are you [b]renaming[/b] the .png into .vtf?
Make sure those 2 files do not exist in any addon or in the download/materials folder.
[QUOTE=Robotboy655;52085730]Wait are you [b]renaming[/b] the .png into .vtf?
Make sure those 2 files do not exist in any addon or in the download/materials folder.[/QUOTE]
No i am using VTFEdit to convert the .png's into .vtf's and .vtm's
I have checked absolutely everywhere in my addons folder, download folders etc and the files are absolutely no where else
Have you tried restarting the game?
Usually PNG files work a lot better than vtf files with stuff like this. It might be worth trying it with the original PNG - that usually works for me at least
[QUOTE=MPan1;52088494]Usually PNG files work a lot better than vtf files with stuff like this. It might be worth trying it with the original PNG - that usually works for me at least[/QUOTE]
Have tried using PNG images again... but still got a black and purple texture error
[QUOTE]Have you tried restarting the game?[/QUOTE]
How much of a reject do you think i am? it's problem with coding not a matter or restarting my game...
[editline]12th April 2017[/editline]
So just to update, I have tried using file.Find to find the file and then concatinate this in the medalimg:SetImage() function... however, now it says that it is trying to concatenate a nil value
I have printed the "material" variable after it has been assigned and should've found the correct file; however, it is returning a nil value for some reason
I'm assuming this means that it cannot find the file... however the png image is in the garrysmod/materials/medals directory
Confusing stuff xD
[CODE]
function medals:DoDoubleClick( lineID , line )
if ( lineID == 1 ) then
local medalpanel = vgui.Create( "DPanel", awardmenu )
medalpanel:SetPos( 400 , 100 )
medalpanel:SetSize( 600 , 600 )
local medalimg = vgui.Create( "DImage", medalpanel )
medalimg:SetPos( 0 , 0 )
medalimg:SetSize( 600 , 600 )
material = file.Find( "materials/medals/medal_4.png", "MOD" )
medalimg:SetImage( "materials/medals/" .. material[1] )
end
[/CODE]
Have you tried:
[CODE]
medalimg:SetImage( "medals/medal_4.png" )
[/CODE]
[QUOTE=MPan1;52093760]Have you tried:
[CODE]
medalimg:SetImage( "medals/medal_4.png" )
[/CODE][/QUOTE]
Yep have tried that, thats the first thing i've tried due to that being what is in the Gmod Wiki... however, it still just shows the black and purple texture error.
I don't understand why it won't work...
I'm not really sure either then... could you post the full filepath? I know you said it was in garrysmod but maybe it's somewhere else
Sorry, you need to Log In to post a reply to this thread.