• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Splerge;49438909]it's calling itself, causing an infinite loop :P[/QUOTE] But why would a parent panel call the children's methods (that it wouldn't even know about)? [QUOTE=Z0mb1n3;49438911]Is it because when you register a new vgui element without a third argument, the panel's baseclass is itself? Therefore, calling the baseclass version of the function, which is a function you just defined, to call the baseclass version, will do exactly what my sentence was about to keep doing and keep repeating...[/QUOTE] The BaseClass is DPanel, though. There is no stackoverflow for any other baseclass method calling in this same panel, such as self.BaseClass.Paint.
[QUOTE=vexx21322;49438916]But why would a parent panel call the children's methods (that it wouldn't even know about)? The BaseClass is DPanel, though. There is no stackoverflow for any other baseclass method calling in this same panel, such as self.BaseClass.Paint.[/QUOTE] Odd. I found [url=https://github.com/garrynewman/garrysmod/blob/3e138636eb1b0ad6ed785dedf350020755cff5f1/garrysmod/lua/vgui/dbutton.lua#L127]this[/url] on the github inside dbutton, and seeing as it references the engine method (?), it seems maybe the base SetEnabled method is at fault.
[QUOTE=Z0mb1n3;49438946]Odd. I found [url=https://github.com/garrynewman/garrysmod/blob/3e138636eb1b0ad6ed785dedf350020755cff5f1/garrysmod/lua/vgui/dbutton.lua#L127]this[/url] on the github inside dbutton, and seeing as it references the engine method (?), it seems maybe the base SetEnabled method is at fault.[/QUOTE] I've been working with garryui fuckery ever since I started working on this, so I guess it doesn't really surprise me. I can just replicate the behavior inside this panel in the mean-time.
[QUOTE=skittles9823;49437906]Hey I was wondering If it is possible to group weapons to be listed under one name in the GUI where you ID a body and it shows what was used to kill them. What it currently looks like: [IMG]https://t.gyazo.com/teams/nwa/d2b59a559112af7533036d7add488e25.png[/IMG] I'm wondering if there is some code to add to make it just show as "CS:GO Knife" pastebin of knife Lua: [url]http://pastebin.com/zf9bjxGY[/url][/QUOTE] Please?
[QUOTE=skittles9823;49439175]Please?[/QUOTE] Did you try changing SWEP.PrintName?
[QUOTE=Z0mb1n3;49438234]It appears that if you don't use numerical keys, the sort function doesn't like it. I'm getting the same result as you.[/QUOTE] That's because it's impossible to sort a non-numerically-indexed table. In a numerically-indexed table you can say "ah entry 1 is the first entry" whereas an associative array for instance can't claim that dog indicates the first entry.
How can I override the default DTextEntry right click menu I tried creating a DermaMenu in the panel's right click function, but that just created both menus at the same time. Any code would really help, since I'm kinda annoyed I can't figure this out myself and it seems pretty simple to me.
[QUOTE=MPan1;49442423]How can I override the default DTextEntry right click menu I tried creating a DermaMenu in the panel's right click function, but that just created both menus at the same time. Any code would really help, since I'm kinda annoyed I can't figure this out myself and it seems pretty simple to me.[/QUOTE] From WAYWO: [QUOTE=Shadow45;49440963]There is a (bad) way of blocking TextEntry's right click menu: [lua] local MYPANEL = vgui.Create( "DTextEntry", frame ) MYPANEL:Dock(FILL) hook.Add( "VGUIMousePressAllowed", "TextEntry_NoRightClickMenu", function( btn ) local Hovered = vgui.GetHoveredPanel() if not IsValid( Hovered ) then return end if not ( IsValid( MYPANEL ) ) then hook.Remove( "VGUIMousePressAllowed", "TextEntry_NoRightClickMenu" ) return end if not ( Hovered == MYPANEL ) then return end if btn == MOUSE_RIGHT then local menu = DermaMenu() menu:AddOption( "hi!", function() print( "hi" ) end ) menu:Open() return true end end ) [/lua] Then make su[/QUOTE]
[QUOTE=GGG KILLER;49439556]Did you try changing SWEP.PrintName?[/QUOTE] That would work, but I would still like the name to show as the correct one, but only in the search results to be "CS:GO Knife".
[QUOTE=LUModder;49442676]Code[/QUOTE] I was thinking about that but I wasn't sure, I'll try it
[QUOTE=skittles9823;49442966]That would work, but I would still like the name to show as the correct one, but only in the search results to be "CS:GO Knife".[/QUOTE] You could gsub the name and replace it.
[QUOTE=LUModder;49443024]You could gsub the name and replace it.[/QUOTE] And how would I begin to do that? Sorry I don't know Lua.
[QUOTE=skittles9823;49443049]And how would I begin to do that? Sorry I don't know Lua.[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/gsub]string.gsub[/url] You'd probably have to make a custom menu for it though.
[QUOTE=LUModder;49443290][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/gsub]string.gsub[/url] You'd probably have to make a custom menu for it though.[/QUOTE] Okay thanks. I'll give this ago with the default menu at first. This may get irritating though as the server has 80 different knives all with different names xD
Is there a way to get the highlighted text of a DTextEntry, or the starting and ending points of the highlight? I found out how to remove the DTextEntry's right click menu and replace it with my own, but now I want to re-add the Cut, Copy and Paste buttons on my DermaMenu as they were before.
Okay so I think I found the correct place to insert [CODE]string.gsub( "", "Butterfly Knife", "CS:GO Knife" )[/CODE] But I dont know how to implement it as its using this: [CODE] local wep = rag.dmgwep or ""[/CODE] and further down, this: [CODE] local wep = util.WeaponFromDamage(dmginfo) rag.dmgwep = IsValid(wep) and wep:GetClass() or ""[/CODE] What should I do?
[QUOTE=MPan1;49443426]Is there a way to get the highlighted text of a DTextEntry, or the starting and ending points of the highlight? I found out how to remove the DTextEntry's right click menu and replace it with my own, but now I want to re-add the Cut, Copy and Paste buttons on my DermaMenu as they were before.[/QUOTE] You can probably use [URL="http://wiki.garrysmod.com/page/Panel/CopySelected"]Panel.CopySelected[/URL] or [URL="http://wiki.garrysmod.com/page/Panel/CutSelected"]Panel.CutSelected[/URL].
Anyone got a way to see how long it takes for a server to launch?
Hey, I get this spammed in my console "GetSpriteAxes: Bad sprite type 1952541999" It's red text. Anyway to remove this with Lua?
[QUOTE=RediL;49446917]Hey, I get this spammed in my console "GetSpriteAxes: Bad sprite type 1952541999" It's red text. Anyway to remove this with Lua?[/QUOTE] Use gm_enginespew to filter/hide/block that message.
Any reason why my timer is disobeying it's check when the two tables are equal to each other [code] timer.Create("CommitGrab.UpdateCommits",60,0,function() CommitGrab.GrabData() CommitGrab.GrabCommitData() timer.Simple(10,function() if CommitGrab.Data[1] != CommitGrab.LatestCommit then CommitGrab.LatestCommit = CommitGrab.Data[1] timer.Simple(1,function() CommitGrab.AnnounceCommit() end) end end) end) [/code] [url=https://github.com/B1IS/FlexBoxV2/blob/master/lua/autorun/server/commitgrab.lua]Full code[/url]
[QUOTE=LUModder;49447973]Any reason why my timer is disobeying it's check when the two tables are equal to each other [code] timer.Create("CommitGrab.UpdateCommits",60,0,function() CommitGrab.GrabData() CommitGrab.GrabCommitData() timer.Simple(10,function() if CommitGrab.Data[1] != CommitGrab.LatestCommit then CommitGrab.LatestCommit = CommitGrab.Data[1] timer.Simple(1,function() CommitGrab.AnnounceCommit() end) end end) end) [/code] [url=https://github.com/B1IS/FlexBoxV2/blob/master/lua/autorun/server/commitgrab.lua]Full code[/url][/QUOTE] Lua compares tables by their references only. The two tables are from two separate util.JsonToTable calls. [editline]3rd January 2016[/editline] Dont bother comparing the two tables by value, the commit hash should be enough
[QUOTE=LUModder;49447973]Any reason why my timer is disobeying it's check when the two tables are equal to each other -code-[/QUOTE] If I'm correct in assuming that CommitGrab.Data[1] and CommitGrab.LatestCommit are tables, then you've found out that the '==' operator doesn't work for tables in lua. You have to loop through each value and check if they are equal.
How would one apply the players health to a .png (i.e. use a picture as the players health bar)? I created an hp smoother and I'm assuming I need to use render.SetScissorRect?
Whats used to make the borders of a DButtob glow when you hover over it?
Is it feasible to replicate chat.AddText's multicolor functionality using draw.SimpleText or something similar? I wanted the text in my DLabels to be multicolored.
[QUOTE=Z0mb1n3;49449084]Is it feasible to replicate chat.AddText's multicolor functionality using draw.SimpleText or something similar? I wanted the text in my DLabels to be multicolored.[/QUOTE] I think you want [URL="https://wiki.garrysmod.com/page/Category:RichText"]RichText[/URL]. My question: Is there an alternative to [URL="http://wiki.garrysmod.com/page/Panel/Paste"]Panel:Paste[/URL] that ACTUALLY WORKS? And, how can you remove the selected text from a panel using Lua rather than user input?
I am a total noob to this, I am trying to drop the weapon in slot 3 for ttt. I thought it would be easy... [CODE] -- Drop a weapon local weapon = nil for k,v in pairs(ply:GetWeapons()) do print (v:GetClass()) print (v.Kind) -- appears to get slot if v.Kind == "3" then -- Drop if slot 3 print ("Wep found" ) weapon = v end end if weapon != nil then ply:DropWeapon( weapon ) print ("dropped" + v:GetClass()) end[/CODE] Where I am checking if the weapon's slot is 3 something isn't working :/ I am getting the value of 3 for third slot as a string, why does it not see 3 == 3?
[code] SWEP.Slot = 7 -- add 1 to get the slot number key [/code] So your example you should use something like [code] if v.Slot == 2 then end [/code] [editline]3rd January 2016[/editline] [QUOTE=Crispyzombie;49449222] Where I am checking if the weapon's slot is 3 something isn't working :/ I am getting the value of 3 for third slot as a string, why does it not see 3 == 3?[/QUOTE] 3 (integer) is not equal to "3" (string).
v.Slot gives me nil for all weapons v.Kind gives me a string value
Sorry, you need to Log In to post a reply to this thread.