Hello.
So I am starting to create my custom VGUI, and was wondering whats the diffrence between: [CODE]derma.DefineControl( )[/CODE]
and
[CODE]vgui.Register( );[/CODE]
I've seen this both being used, and wasn't sure exactly what fits my needs.
[QUOTE=YourStalker;48565866]What map, it could be either custom models in that map or they are/were shitty mappers and managed to fuck up badly. I don't think I've ever gotten this before in TTT.[/QUOTE]
The issue just came up on ttt_mc_ mineshaft at the moment.
[QUOTE=tzahush;48565967]Hello.
So I am starting to create my custom VGUI, and was wondering whats the diffrence between: [CODE]derma.DefineControl( )[/CODE]
and
[CODE]vgui.Register( );[/CODE]
I've seen this both being used, and wasn't sure exactly what fits my needs.[/QUOTE]
someone smarter than me correct me if I'm wrong, but...
DefineControl adds a new control to the game (checkbox, sliders, number wangs, etc.), which is 99% of the time used internally and you shouldn't need to use.
vgui.Register registers a new VGUI component, which is more suitable to your needs, and is used to create custom menus and scoreboards and the likes.
derma.DefineControl does the same stuff as vgui.Register but also:
- creates a global variable of your element's name
- has autorefresh support
How do people make "server addons"? (updates that go into addons folder) Let's say I want to edit a gamemode's cl_hud.lua. Do I just do that and pack it as an addons folder?
Won't that conflict with the original cl_hud.lua file? And what if you want to make 2 separate addons for the cl_hud.lua? Do people write "put this and this line into cl_hud.lua" lua files or what? Sorry if that didn't make sense.
[editline]29th August 2015[/editline]
Anyways if this is too complicated: how are the server addons on scriptfodder packed? (directory structure and all that)
Surely there is a method to use a map's navmesh to create my own AI right? I want entities to use path finding like nextbots do (but they aren't nextbots) and I can't seem to find any way to do it. All I really need is a table of vectors between 2 points
I'm working on a team selection panel.
When I pull the panel up, it looks like this:
[IMG]http://i.imgur.com/5s9ygt9.jpg[/IMG]
The alignment on the "Cancel" button is all jacked up.
But when I go to the Esc menu, it does this:
[IMG]http://i.imgur.com/w6IGBt3.jpg[/IMG]
Everything is aligned correctly. But when I exit that menu, it reverts back to the first image.
Here's what's making it:
[CODE]local function DrawButton( w, h, bgcolor, label )
local button = { { x = 0, y = 0 }, { x = w, y = 0 }, { x = w, y = ( ( h / 3 ) * 2 ) }, { x = ( ( w / 12 ) * 11.35 ), y = h }, { x = 0, y = h } }
local txtW, txtH = surface.GetTextSize( label )
surface.SetDrawColor( bgcolor )
draw.NoTexture()
surface.DrawPoly( button )
draw.SimpleText( label, "TS_ButtonLabels", ( w - txtW) / 2, ( h - txtH ) / 2, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
end
function PANEL:Init()
self:SetSize( ScrW(), ScrH() )
local buttonCont = vgui.Create( "DPanel", self )
buttonCont:SetSize( (ScrW() / 8) * 6, ScrH() / 20 )
buttonCont:SetPos( (ScrW() / 2) - (buttonCont:GetWide() / 2), (ScrH() / 2) - (buttonCont:GetTall() / 2) )
local btnW, btnH = ( ( buttonCont:GetWide() - 20 ) / 5 ), ( buttonCont:GetTall() - 10 )
local cancel = vgui.Create( "DPanel", buttonCont )
cancel:SetSize( btnW, btnH )
cancel:DockMargin( 5, 5, 5, 5 )
cancel:Dock( RIGHT )
cancel.Paint = function( pnl, w, h )
DrawButton( cancel:GetWide(), cancel:GetTall(), COLOR_GREY, "Cancel" )
end
local spec = vgui.Create( "DPanel", buttonCont )
spec:SetSize( btnW, btnH )
spec:DockMargin( 5, 5, 5, 5 )
spec:Dock( RIGHT )
spec.Paint = function( pnl, w, h )
DrawButton( spec:GetWide(), spec:GetTall(), COLOR_GREY, "Spectate" )
end
end[/CODE]
Any ideas why it's being so screwy?
[QUOTE=wranders;48567874]
Any ideas why it's being so screwy?[/QUOTE]
Surface.GetTextSize is being dumb from my testing. I replaced it with 70,30 and for my resolution it works now, so maybe try a different way of retreiving text size?
[QUOTE=wranders;48567874]I'm working on a team selection panel.
When I pull the panel up, it looks like this:
[IMG]http://i.imgur.com/5s9ygt9.jpg[/IMG]
The alignment on the "Cancel" button is all jacked up.
But when I go to the Esc menu, it does this:
[IMG]http://i.imgur.com/w6IGBt3.jpg[/IMG]
Everything is aligned correctly. But when I exit that menu, it reverts back to the first image.
Here's what's making it:
code
Any ideas why it's being so screwy?[/QUOTE]
you have to call surface.SetFont(fontname) before surface.GetTextSize
[QUOTE=zerf;48569775]you have to call surface.SetFont(fontname) before surface.GetTextSize[/QUOTE]
Good call. Thanks!
Stupid question, but how would I get the first word of a string (e.g. 'Test string' > 'Test')
[QUOTE=MPan1;48571131]Stupid question, but how would I get the first word of a string (e.g. 'Test string' > 'Test')[/QUOTE]
local wordz = "Test String"
local WordsExplode = string.Explode( " ", wordz )
PrintTable( WordsExplode )
will return:
1 = Test
2 = String
[QUOTE=MPan1;48571131]Stupid question, but how would I get the first word of a string (e.g. 'Test string' > 'Test')[/QUOTE]
String patterns?
[lua]print(("hello, there fellas."):match("%w*"))
returns:hello[/lua]
Or if you want to explode everything by a space, use string.Explode;
[lua]local str = "hello, there fellas."
local tbl = string.Explode(" ", str)
tbl = {"hello,", "there", "fellas."}[/lua]
Thanks- this worked (and created less vars)-
[CODE]
print(("hello there fellas."):match("%S*"))
[/CODE]
I was using gmatch before...
I'm currently trying to spawn npc's with a random player color, which is determined by what $color2 is set to.
I know when they spawn, they have a default color set, well i'd like to randomize that with a lua script upon spawning, I'm just looking for some help as to how i'd call on the $color2 and change it.
any help would be appreciated.
Is there anyway of looping through all of my Derma elements that i have on my VGUI, for example looping through all labels.
Thanks.
[QUOTE=tzahush;48572480]Is there anyway of looping through all of my Derma elements that i have on my VGUI, for example looping through all labels.
Thanks.[/QUOTE]
You can insert the labels into a table once they're created and loop through that
[QUOTE=Exho;48567768]Surely there is a method to use a map's navmesh to create my own AI right? I want entities to use path finding like nextbots do (but they aren't nextbots) and I can't seem to find any way to do it. All I really need is a table of vectors between 2 points[/QUOTE]
[url]http://wiki.garrysmod.com/page/Global/Path[/url]
The NextBot base entity is written Lua so it is really easy to see how they work: [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/entities/base_nextbot/sv_nextbot.lua[/url]
Is "[B]ScoreboardText[/B]" still a valid font anywhere within Garry's Mod? I'm dealing with an older Wire Extras tool and getting the following:
[code][ERROR] lua/includes/modules/draw.lua:146: 'ScoreboardText' isn't a valid font[/code]
If you know of a font that has replaced ScoreboardText, let me know. I'd like to create an issue/request on the Wire-Extras GitHub page.
Snip
Is there a way to retrieve the ragdoll entity an NPC creates on death?
[QUOTE=Z0mb1n3;48573355]Is there a way to retrieve the ragdoll entity an NPC creates on death?[/QUOTE]
-snip- DERP
Is there any reason no clientside hooks are called at all for Nextbot AI?
For example:
[lua]
ENT.Base = "base_entity";
function ENT:Initialize()
print("abc");
end
[/lua]
Would print "abc" on both client and server but;
[lua]
ENT.Base = "base_nextbot";
function ENT:Initialize()
print("abc");
end
[/lua]
Would print "abc" only on the server. Other hooks don't seem to be working either, specifically [url=http://wiki.garrysmod.com/page/ENTITY/RenderOverride]ENTITY:RenderOverride[/url] and [url=http://wiki.garrysmod.com/page/ENTITY/Draw]ENTITY:Draw[/url]. I haven't checked any other hooks.
[QUOTE=>>oubliette<<;48574418]Is there any reason no clientside hooks are called at all for Nextbot AI?
For example:
[lua]
ENT.Base = "base_entity";
function ENT:Initialize()
print("abc");
end
[/lua]
Would print "abc" on both client and server but;
[lua]
ENT.Base = "base_nextbot";
function ENT:Initialize()
print("abc");
end
[/lua]
Would print "abc" only on the server. Other hooks don't seem to be working either, specifically [url=http://wiki.garrysmod.com/page/ENTITY/RenderOverride]ENTITY:RenderOverride[/url] and [url=http://wiki.garrysmod.com/page/ENTITY/Draw]ENTITY:Draw[/url]. I haven't checked any other hooks.[/QUOTE]
Nextbots don't have a client interface as far as I know.
The CSent created by ClientsideRagdoll refuses to allow me to use SetPos on it. Why?
EDIT:
Ok, had to use the physics object. I don't know much about clientside ragdolls, so when I use SetBonePosition, it tells me "Bone is unwritable" in console...
Another stupid VGUI question INC:
I am using a for loop to loop through a table, and adding a picture and a label.
Because the label is not the same amount of characters, it's just doesn't 'center' it self in front of the picture.
This is an example of whats happening to me, first one is the wanted, second one is whats happening.
[IMG]http://puu.sh/jUeEz/2627d35543.png[/IMG]
How can i center it realitvly to the picture any thoughts?
My server causes players to crash from time to time giving them the error message
[quote]
too many indices for index buffer. . tell a programmer (43350>32768)[/quote]
Some players have 36882>32768, the numbers might change from person to person, as I don't have everyone sending them to me. Is there something I could do to fix this?
[QUOTE=KnightDmG;48576846]My server causes players to crash from time to time giving them the error message
Some players have 36882>32768, the numbers might change from person to person, as I don't have everyone sending them to me. Is there something I could do to fix this?[/QUOTE]
We had this issue once. I changed the map and it seemed to go away, but somehow I'm doubting it's the map as others run the same version.
What map are you using out of curiosity?
What is the correct way to move an Entity (not apply force to it, just move it)?
I tried putting it into ENT:Think(), but this is running based on the clients Frames, so it's completly different on each player. Or is this the only way?
So, what would be a good goal for a Wire E2 in terms of ops? is 150 ok?
Sorry, you need to Log In to post a reply to this thread.