Hey!
I had the lua_run(_cl) command before that did something like this:
It gets your player, then it gets what entity you're looking on.
And returns the EntIndex() of the entity in console.
I of course forgot how I made that one.
Could someone recreate it please?
Thanks
[editline]06:15PM[/editline]
Not sure if it was EntIndex() now.
But it prints out all info about that entity.
Like material path, and so on
lua_run_cl print(LocalPlayer():GetEyeTrace().Entity)
Ent index and class will be printed
Thanks!
But I would need to get the material of the entity.
[b][url=http://wiki.garrysmod.com/?title=Entity.GetMaterial]Entity.GetMaterial [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
I used this one, and made:
[lua]
lua_run_cl print(LocalPlayer():GetEyeTrace().Entity:GetMaterial())
[/lua]
But it only prints a empty line. Like a "\n"
You can only get the material if it's an override material (like when you use the material stool) the models default texture is inaccessible.
Ah shoot..
I know its somehow possible. But I don't remember how :/
It was some kind of function that printed a whole list with info of the entity, including texture and so on. (It even worked when I looked at a brush, and I could get a texture out of it)
[QUOTE=ralle105;24711245]You can only get the material if it's an override material (like when you use the material stool) the models default texture is inaccessible.[/QUOTE]
You can with the modelinfo module.
[QUOTE=Jamie932;24711516]You can with the modelinfo module.[/QUOTE]
And how does that work?
[QUOTE=Blt950;24711621]And how does that work?[/QUOTE]
[url=http://www.facepunch.com/showthread.php?t=802281]The thread about it is here.[/url] I used the following code with it:
[lua]function GetModelMaterial(ply, cmd, args)
if !args[1] then print("Error") return end
local nIndex = modelinfo.GetIndex( Model( args[1] ) );
print( modelinfo.GetMaterials( nIndex ) );
end
concommand.Add("GetModelMaterial", GetModelMaterial)[/lua] Its serverside. Put it in autorun/server and just type GetModelMaterial "modelnamehere" in the console.
hmm..
Okey.. Well I installed it.. in lua/includes/modules
But I get this though:
[code]
] GetModelMaterial "models/gantry_crane/crane_trolley.mdl"
[lua\autorun\print_errors.lua:22] attempt to index global 'modelinfo' (a nil value)
[/code]
[editline]08:11PM[/editline]
Line 22: local nIndex = modelinfo.GetIndex( Model( args[1] ) );
you need to require it.
[QUOTE=Callee;24712291]you need to require it.[/QUOTE]
Please explain what you mean?
Add require( "modelinfo" ) at the top of your lua file
Okey! Now I got rid of that problem. But next problem:
[code]
] GetModelMaterial "models/gantry_crane/crane_trolley.mdl"
[lua\autorun\print_errors.lua:24] attempt to call field 'GetIndex' (a nil value)
[/code]
[editline]08:36PM[/editline]
Okey, never mind. I finally got what I wanted. By some help from someone else:
lua_run PrintTable(Entity(1):GetEyeTrace())
Sorry, you need to Log In to post a reply to this thread.