Ulysses
General => Developers Corner => Topic started by: Zmaster on April 19, 2014, 05:27:16 PM
-
I've been trying to add the image at the bottom of this post as a trail on my pointshop, however, I've been having some trouble.
I have the code for the item itself in the pointshop folder. It's path: C:\GMOD\garrysmod\addons\pointshop-master\lua\items\trails\trail01.lua
The code in that file:
ITEM.Name = 'Saw'
ITEM.Price = 500
ITEM.Material = 'trails/Trail01.vmt'
function ITEM:OnEquip(ply, modifications)
ply.Trail01 = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end
function ITEM:OnHolster(ply)
SafeRemoveEntity(ply.Saw)
end
function ITEM:Modify(modifications)
PS:ShowColorChooser(self, modifications)
end
function ITEM:OnModify(ply, modifications)
SafeRemoveEntity(ply.Saw)
self:OnEquip(ply, modifications)
end
The only reason I was able to get that code was because of copying and pasting from other sites. :P
When I'm ingame, the "Saw" trail option does appear, but it shows the error texture.
(http://puu.sh/8fAQd.png)
I put the "Trail01.vmt" and "Trail01.vtf" files in it's own addon folder, since I wasn't sure where to put it. I named the addons folder "ZsAddons" and all that's in it is the "info.txt" file and the materials folder. Inside the materials folder is a folder named trails, and inside of the trails folder is the VMF and VTF files.
I was hoping someone here could help me get the textures to download for clients when they join the server so that they would have the texture and be able to see it.
(https://i.imgur.com/LH4S3wD.png)
-
resource.AddFile
http://wiki.garrysmod.com/page/resource/AddFile (http://wiki.garrysmod.com/page/resource/AddFile)
-
Edit:
Today I started up my server and was running around. Now when I walk a trail does show up, but it shows the purple and black checkerboard texture (Missing Texture) instead of the image.
Go to this link to see what I'm talking about ---> http://puu.sh/8grOR.jpg (http://puu.sh/8grOR.jpg)
-
It's been 21 days. :P Does anybody know how to fix this?
-
It could be a number of things.
You can't really expect anyone to know how to fix your issue when you just come on here and say:
"I have a missing texture, can you fix it?"
You might start by making sure that the texture is being sent to the clients and that your code points to the right location for the texture.
-
Did you put the textures in the correct place?
MyAddonName/materials/UniqueFolderName/
If you don't want the unique folder then go ahead and put it in /materials.
Do note that if you do that, you may have conflicting textures if you get textures of the same name from another server since the texture names are generic.
-
Sorry for the wait. I've been busy for the past few days. :)
"You might start by making sure that the texture is being sent to the clients and that your code points to the right location for the texture."
The clients definitely download the file.
And I'm sure the code is pointing to the right location.
"MyAddonName/materials/UniqueFolderName/"
Yea, that's where the files are
-
And I'm sure the code is pointing to the right location.
"MyAddonName/materials/UniqueFolderName/"
Yea, that's where the files are
If you're code is pointing to that path, then that is likely your problem.
See my response to someone regarding downloading files.
http://forums.ulyssesmod.net/index.php/topic,7260.msg36572.html#msg36572 (http://forums.ulyssesmod.net/index.php/topic,7260.msg36572.html#msg36572)
Though the question was different, the answer is the same.
Don't include the addon folder name in the path of your code.
Use the 'real' virtual path,
-
If you place things into an addon folder, you must use its contents like they were installed directly into the root, instead of the addons folder and from there.
-
Alright, since having my own addon for the textures is more complicated, I decided to just move the files to the materials folder and name it something that's probably not going to be used by anyone else. (ZmaSaw.vmt and ZmaSaw.vtf)
I changed the paths in the files to the new path of the files. (materials/ZmaSaw)
JamminR, the paths are the right way, now, according to what you said in that thread.
Neku, you basically said the same thing as JamminR, but more condensed. Same thing with you. It's the right location now.
Still shows the missing texture when I equip the trail igname.
-
Well, are you using the correct vmt setup?
-
Well, are you using the correct vmt setup?
"UnlitGeneric"
{
"$basetexture" "materials/ZmaSaw"
"$vertexalpha" 1
"$vertexcolor" 1
}
Is that right?
-
Is Zmasaw a folder or the texture?
-
ZmaSaw is the the name of the two texture files
(.vmt and .vtf)
-
Hm, I'm quite stumped on this one.
-
Since nobody can find a problem with the info I provided, I'm gonna post everything I can think of that is related to the trail.
Locations of the files:
ZmaSaw.vmt and ZmaSaw.vtf:
C:\GMOD\garrysmod\materials\ZmaSaw.vmt
C:\GMOD\garrysmod\materials\ZmaSaw.vtf
(Code/whatever is in the vmt is below)
File that makes client download the vtfs and vmts:
C:\GMOD\garrysmod\addons\ZsAddons\lua\autorun\my_trails_stuff.lua
(Code in this file is below)
File in pointshop addon folder that adds it to the shop:
C:\GMOD\garrysmod\addons\pointshop-master\lua\items\trails\zmasaw.lua
(Code in this file is below)
Code for the files:
zmasaw.lua code (Pointshop file)
ITEM.Name = 'Saw'
ITEM.Price = 500
ITEM.Material = 'materials/ZmaSaw.vmt'
function ITEM:OnEquip(ply, modifications)
ply.LaserTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end
function ITEM:OnHolster(ply)
SafeRemoveEntity(ply.LaserTrail)
end
function ITEM:Modify(modifications)
PS:ShowColorChooser(self, modifications)
end
function ITEM:OnModify(ply, modifications)
SafeRemoveEntity(ply.LaserTrail)
self:OnEquip(ply, modifications)
end
my_trails_stuff.lua (File that makes clients download the vmts and vtfs)
if (SERVER) then
resource.AddFile( "materials/ZmaSaw.vmt" )
resource.AddFile( "materials/ZmaSaw.vtf" )
end
ZmaSaw.vmt (Self explanatory)
"UnlitGeneric"
{
"$basetexture" "materials/ZmaSaw"
"$vertexalpha" 1
"$vertexcolor" 1
}
-
In your material path, it's relative to the materials folder. You don't need to include it.
Your code is looking for : materials/materials/ZmaSaw.vmt
change your ITEM.Material to
ITEM.Material = 'ZmaSaw.vmt'
-
In your material path, it's relative to the materials folder. You don't need to include it.
Your code is looking for : materials/materials/ZmaSaw.vmt
change your ITEM.Material to
ITEM.Material = 'ZmaSaw.vmt'
Er, not vmt. Use vtf.
Edit: Oh, I've never made a trail myself, sorry about the bad info.
-
Er, not vmt. Use vtf.
No... You are supposed to use the vmt with SpriteTrail.
http://wiki.garrysmod.com/page/util/SpriteTrail (http://wiki.garrysmod.com/page/util/SpriteTrail)
http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index73b0.html (http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index73b0.html)
Also, right from the valve wiki (Just for learning points):
A texture is a two-dimensional raster image in the context of a game engine. Textures in Source are stored in the Valve Texture Format, and with a very few exceptions are only accessed through an intermediate material.
-
A .vmt is what source uses as a texture. It has all of the information the engine needs to display the graphic. (INCLUDING a link to the actual image itself which is the .vtf)
A .vtf is just the image that a .vmt uses.
-
Okay, did what you said.
Changed materials/ZmaSaw.vmt to ZmaSaw.vmt
Now, I join the server. I equip the trail. But instead of showing the missing texture thing, it shows nothing at all.
-
Well, this is a start.
Having is show nothing, means that it's at least not pointing to something that doesn't exist.
Have you manually edited the .vtf at all?
-
I've manually edited the .vmt once, but not the .vtf
Did you mean that?
-
Yeah, that's what I meant. Sorry.
What did you change? That could have caused an issue.
Also, is it possible that modifications.color isn't being set? That might be why it's invisible as well. You might changing that to something like.. Color(255,255,255,255) just as a test.
-
In an example right from the valve website (https://developer.valvesoftware.com/wiki/Material)
They have
$basetexture coast\shingle_01
try changing yours to:
$basetexture ZmaSaw
-
"What did you change? That could have caused an issue."
I believe all I did was change the location of the ZmaSaw thing after the "$basetexture" part of it
"Also, is it possible that modifications.color isn't being set? That might be why it's invisible as well. You might changing that to something like.. Color(255,255,255,255) just as a test."
Where would I do that? Ingame? If so, that's what it's set to there.
(http://puu.sh/99k3O/528c8e1939.jpg)
"They have
$basetexture coast\shingle_01
try changing yours to:
$basetexture ZmaSaw"
Just did this.
"UnlitGeneric"
{
"$basetexture" "ZmaSaw"
"$vertexalpha" 1
"$vertexcolor" 1
}
Still shows nothing when I walk around.
-
Are you seeing anything in your client console about missing textures or anything like that?
Other than the things I've already suggested, I don't really know what else is going on. I use PNG files for all my GUI/Material stuff now since GM13 allows it. I'm not super familiar with VMT/VTF.
-
I've gone ahead and dug up a couple of .vmt's belonging to trails.
"UnlitGeneric"
{
"$baseTexture" "trails/8bitarrow"
"$additive" 0
"$vertexcolor" 1
"$vertexalpha" 1
}
From what I've seen from your's, it does not include $additive.
-
For Neku:
I added the part that was missing
Now when I go to the PointShop, it will show the correct image in the PointShop, but when I walk around after equipping the trail, it shows nothing.
(http://puu.sh/99Aa4/2fa2ea7a18.jpg)
For MrPresident:
I didn't check before this, but after I fixed the thing Neku told me to do (talked about it earlier in this post), I have nothing in my client console that says anything related to the missing texture.
Current Problem: Correct image of trail shows when in PointShop menu. It does not show when I walk around. (Nothing shows at all when I walk around)
-
ITEM.Name = 'Saw'
ITEM.Price = 500
ITEM.Material = 'materials/ZmaSaw.vmt'
function ITEM:OnEquip(ply, modifications)
ply.LaserTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end
function ITEM:OnHolster(ply)
SafeRemoveEntity(ply.LaserTrail)
end
function ITEM:Modify(modifications)
PS:ShowColorChooser(self, modifications)
end
function ITEM:OnModify(ply, modifications)
SafeRemoveEntity(ply.LaserTrail)
self:OnEquip(ply, modifications)
end
This is your item.lua. You still have the ply.LaserTrail in that. Change it to something like, ply.SawTrail.
It should look like this:
ITEM.Name = 'Saw'
ITEM.Price = 500
ITEM.Material = 'materials/ZmaSaw.vmt'
function ITEM:OnEquip(ply, modifications)
ply.SawTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end
function ITEM:OnHolster(ply)
SafeRemoveEntity(ply.SawTrail)
end
function ITEM:Modify(modifications)
PS:ShowColorChooser(self, modifications)
end
function ITEM:OnModify(ply, modifications)
SafeRemoveEntity(ply.SawTrail)
self:OnEquip(ply, modifications)
end
I'm not saying this will fix it, but it was conflicting with your laser trail.
-
Did as you said. As you exptected, it still does not fix the problem. Image shows in PointShop menu, does not show when I walk.
Just noticed this in client console, by the way.
(http://puu.sh/99Gap/14f871b096.png)
(Not sure what that means)
-
Looks like you still have references to (what appears to be) an older version of the material somewhere in your code that it's trying to load.
This is why it's not recommended to edit material and texture files by hand.
It's also possible that particular material just won't work as a trail. This is not as likely, but anything is possible.
In source, when a material fails to load or is missing, it shows as a purple and black checkerboard. The fact that yours is just *invisible* means that it is loading, you just can't see it.
-
Did you make the material files yourself, or did you just find it?
-
I found the Saw image online, but I made it into a .vmt and .vtf
I'll get to what MrPresident said soon
-
For MrPresident:
To make sure there was nothing wrong with the thing you said about referencing an old .vmt, I changed the name of it and changed the name in all of the files to sync it up.
I also moved the .vmt and .vtf from the materials folder to materials/trails.
It works perfectly now. (Besides it being a little small, but I can fix that)
I also created a second trail to make sure I can do it, and that works fine too.
(http://puu.sh/9aNCu/2ce92270d5.jpg)
Thanks so much for all of the help! I "complimented" both of you! (Neku and MrPresident)
-
Good! I'm glad that you got it working.
We're always here to help you, even if it takes some time to hash out the problem.
-
BUMP
I'm having the same problem.
Zee is one of my buddies trying to help me through Steam but that didn't seem to help.
I pretty much did everything he did but i'm having missing textures in the pointshop menu of the trails icon, and in game when I purchase it there is no trail following behind me.
Here's also the code for one of my VMT files
"UnlitGeneric"
{
"$baseTexture" "trails/mine/anon"
"$additive" 0
"$vertexalpha" 1
"$vertexcolor" 1
}