• Hovering letters above a prop when you look at it.
    17 replies, posted
Hey guys, i've been messing around with some things, and I want to know, how do you make it that if you look at a specific model, like a box, it shows up BOX in the middle of the screen when u look at it? Help would be greatly appreciated.
Letters like? Model path or Owner of the prop?
Model Path.
So basically you want a Small Transparent VGUI That comes up with a small picture of the prop and its name?
No, I dont want model path to be displayed, but, if you look at that specific model path, that a text shows up.
What letters does a text consist of if i spawn a melon?
[QUOTE=Staneh;22578674]if you look at that specific model path, that a text shows up.[/QUOTE] It's not a specific model path, just a specific model. Like, if you look at a melon, a HUD or something comes above it, like when looking at a player, and seeing his name, it's LULMELON.
I think he wants the "pretty" name of what prop he is looking at, for example if he was looking at a chair, it would print "chair" somewhere.
As stated in the post above you. Im unfortuneately unable to help you, though.
Gah, rate me bad reading.
[lua] local niceNames = { ["path/to/model"] = "Nice Name", ["etc/etc/etc"] = "Nice Etc" } hook.Add("HUDPaint", "TestScreen", function() local tr = LocalPlayer():GetEyeTrace() if tr.Entity then local x, y = tr.Entity:GetPos():ToScreen() draw.SimpleText(niceNames[tr.Entity:GetModel():lower()] or "Unknown", "Default", x, y, Color(255, 255, 255, 255), 1, 1) end end) [/lua] Something like this then?
[QUOTE=ralle105;22605255][lua] local niceNames = { ["path/to/model"] = "Nice Name", ["etc/etc/etc"] = "Nice Etc" } hook.Add("HUDPaint", "TestScreen", function() local tr = LocalPlayer():GetEyeTrace() if tr.Entity then local x, y = tr.Entity:GetPos():ToScreen() draw.SimpleText(niceNames[tr.Entity:GetModel():lower()] or "Unknown", "Default", x, y, Color(255, 255, 255, 255), 1, 1) end end) [/lua] Something like this then?[/QUOTE] This one does not work. [B]Hook 'TestScreen' Failed: lua\includes\modules\draw.lua:76: attempt to perform arithmetic on local 'x' (a table value)[/B]
[lua] local niceNames = { ["path/to/model"] = "Nice Name", ["etc/etc/etc"] = "Nice Etc" } hook.Add("HUDPaint", "TestScreen", function() local tr = LocalPlayer():GetEyeTrace() if tr.Entity and !tr.Entity:IsWorld() then local p = tr.Entity:GetPos():ToScreen() draw.SimpleText(niceNames[tr.Entity:GetModel():lower()] or "Unknown", "Default", p.x, p.y, Color(255, 255, 255, 255), 1, 1) end end) [/lua] Try this instead.
Isn't it string.lower(tr.Entity:GetModel())? somestring:lower() looks like something out of E2.
It works, but while I'm not looking at anything, it says "Unknown" at the middle of the map (Vector(0,0,0)). [B]Simple solution:[/B] Change "Unknown" to " ".
[QUOTE=MegaJohnny;22647318]Isn't it string.lower(tr.Entity:GetModel())? somestring:lower() looks like something out of E2.[/QUOTE] In gmod strings have the string table as meta table so any string function can be called either by string.whatever(str,...) or str:whatever(...) it does the exact same thing:wink: [editline]02:54AM[/editline] [QUOTE=Bagasen;22647367]It works, but while I'm not looking at anything, it says "Unknown" at the middle of the map (Vector(0,0,0)). [B]Simple solution:[/B] Change "Unknown" to " ".[/QUOTE] Fixed that:v:
Awesome, thanks.
Sorry, you need to Log In to post a reply to this thread.