Panel Invalidation problems

Right well, I know I’ve come here for a lot of help, but I want you all to know I appreciate it very much. Now onto the problem, I’ve been trying to add a bit of derma to the inventory system I’ve been working on and it doesn’t want to invalidate for some reason. Here’s the code.
[lua]function TestInventoryDerma()
local client = LocalPlayer()
if !client:Alive() then return end
if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == “Camera”) then return end

local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
DermaPanel:SetPos( ScrW()/2 - 200 ,150 ) -- Position on the players screen
DermaPanel:SetSize( 400, 700 ) -- Size of the frame
DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) -- Draggable by mouse?
DermaPanel:ShowCloseButton( true ) -- Show the close button?
DermaPanel:MakePopup() -- Show the frame

DermaList = vgui.Create( "DPanelList", DermaPanel )
DermaList:SetPos( 17,30 )
DermaList:SetSize( 366, 650 )
DermaList:SetSpacing( 0 ) -- Spacing between items
DermaList:EnableHorizontal( false ) -- Only vertical items
DermaList:EnableVerticalScrollbar( true )

for k, v in pairs(cInventory) do
	if( v >= 1) then
		local panel = vgui.Create("DPanel", DermaList)
		panel:SetSize( 266, 50)
		DermaList:AddItem( panel )
		local spawnIcon = vgui.Create("SpawnIcon", panel)
		spawnIcon:SetModel( itemTable[k].modelPath)
		spawnIcon.OnCursorEntered = function()
			return false
		spawnIcon.OnMousePressed = function(btn)
			local MenuButtonOptions = DermaMenu()
			MenuButtonOptions:AddOption("Drop", function() 
				RunConsoleCommand("dropItem", k)
				DermaPanel:InvalidateLayout(true) end)
		local name = vgui.Create("DLabel", panel)
		name:SetPos( 55, 5)
		local amount = vgui.Create("DLabel", panel)
		amount:SetPos( 55, 25)
		local weight = vgui.Create("DLabel", panel)
		weight:SetText("Weight:"..itemTable[k].weight.." lbs")
		weight:SetPos( 120, 25)
		local totalWeight = vgui.Create("DLabel", panel)
		totalWeight:SetText("Total Weight:"..itemTable[k].weight * v.." lbs")
		totalWeight:SetPos( 200, 25)

concommand.Add(“TestInventoryDerma”, TestInventoryDerma)[/lua]

There’s no error, it just won’t refresh the panel so that it will adjust to the current amount of items a player has.

Shouldn’t you hook it to a “Think” hook?

I was looking for an answer not a question! I’ll try it and see how it works, although I’d like the help to be confident.

Edit:Yeah you’re going to need to be more specific than that, It’s still not working.

It won’t update if you don’t call an update function. So yes, use Think.

I’m telling you, I called the think hook with
function DermaPanel:Think()

Do I have to make a custom vgui set for this to work properly?


Set the DermaPanel:InvalidateLayout() to self:InvalidateLayout() and it still didn’t work.

you need to use

[lua]hook.Add( “Think”, “TestInventoryDerma”, TestInventoryDerma )[/lua]

After the function

No you’re stupid that will just spam people with derma frames.

fine then, do a PANEL:Think() function instead



I told you, I tried that bullshit. Nobodies answering my question, if I wanted to refresh a derma panel to rebuild, 1.) do I have to create a custom VGUI panel 2.) do I have to call PerformLayout() and InvalidateLayout()?

Try harder and stop posting for help, you obviously don’t need it.

lol fuck you, there’s help to be had, but you two suck so terribly it’s laughable, but you do have a point with the whole doing shit on your own argument. I’ll come back after I’ve tried EVERYTHING.

You obviously suck because you have no-idea of what you’re doing you’re incredible stupid, we’ve told you what to do, L2R.


I haven’t messed much with InvalidateLayout before, but if it isn’t working you could just manually refresh all the values yourself by doing list:Clear() and then adding all the items back.

Yeah I tried it and initially it didn’t work. After that I planned out the derma as a custom VGUI panel and it worked when used in conjunction with PANEL:InvalidateLayout(). Thanks for some helpful advice Entoros. I’m glad you can read.