Hello and thanks for taking your time to read about my issue:
I'm making a gamemode and I wanted people to easily be able to create maps without worrying about Lua at all. I wanted to be able to create a brush entity in Hammer and detect it via lua to apply the corresponding logic. I got pretty far on my own but my materials (defined with Hammer's texture tool) are not showing up.
I've created a simple entity setting [I][B]ENT.Base[/B][/I] to "base_brush" and [I][B]ENT.Type[/B][/I] to "brush". I've also defined the entity as a [I][B]@SolidClass[/B][/I] in my fgd file. To check that everything works I've made it so that a message is shown when [I][B]ENT:StartTouch([/B])[/I]. Everything seems fine, but I can't get the material defined in Hammer to show up.
Printing [B][I]self:GetMaterials()[1][/I][/B] returns the correct material ([I]maps/gmodmap/dev/dev_blendmeasure_wvt_patch[/I]) but even when I try to [B][I]self:SetMaterial()[/I][/B] I can't get it to work.
I also get the following error: [I][B]Requesting texture value from var "$dummyvar" which is not a texture value (material: NULL material)[/B][/I]
[CODE]
ENT = {}
ENT.Base = "base_brush"
ENT.Type = "brush"
function ENT:Initialize( key, value )
print(self:GetMaterials()[1])
self:SetMaterial(self:GetMaterials()[1], true)
end
function ENT:KeyValue( key, value )
if !self.keyvalues then
self.keyvalues = {}
end
print(key, value)
self.keyvalues[key] = value
end
if ENT.Type then
scripted_ents.Register( _G.ENT, "start_line" )
end
function ENT:StartTouch( entity )
if entity:IsPlayer() and entity:IsValid() then
for _, v in pairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTTALK, entity:GetName().. " touched it OMG.")
end
end
end
ENT = nil[/CODE]
I swear that code is just for quick testing purposes, I'll write it in a cleaner way once I figure out all the details :excited:
Thanks for the help
A bit late, but you should look in this: [url]http://wiki.garrysmod.com/page/IMesh/Draw[/url]
Or this: [url]http://wiki.garrysmod.com/page/Category:mesh[/url]
I don't think their is an "Automated function" for this, you must draw it manualy
[QUOTE=guigui;49522166]A bit late, but you should look in this: [url]http://wiki.garrysmod.com/page/IMesh/Draw[/url]
Or this: [url]http://wiki.garrysmod.com/page/Category:mesh[/url]
I don't think their is an "Automated function" for this, you must draw it manualy[/QUOTE]
Are you suggesting that I should use the entity only to the purposes of getting the dimensions of the original brush and then drawing it myself?
Is there any possibility that this is just the script being unable to access the material path? I guess that the material would be located inside the .bsp file right?
Try this clientside
[lua]function ENT:Draw()
self:DrawModel()
end[/lua]
If you are lucky, maybe it will work just fine
[QUOTE=guigui;49528101]Try this clientside
[lua]function ENT:Draw()
self:DrawModel()
end[/lua]
If you are lucky, maybe it will work just fine[/QUOTE]
Brush entities are serverside only iirc.
I've set up a brush entity before. I don't recall exactly what I did, but I do recall needing to set the model, possibly from a keyvalue. If there's a keyvalue that has a string value that looks like "*5" (but with any number), use that as the model.
Sorry, you need to Log In to post a reply to this thread.