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:SetToolTip(false)
		spawnIcon:SetIconSize(50)
		spawnIcon.OnCursorEntered = function()
			return false
		end
		spawnIcon.OnMousePressed = function(btn)
			local MenuButtonOptions = DermaMenu()
			MenuButtonOptions:AddOption("Drop", function() 
				RunConsoleCommand("dropItem", k)
				DermaPanel:InvalidateLayout(true) end)
			MenuButtonOptions:Open()
		end
		
		local name = vgui.Create("DLabel", panel)
		name:SetText(itemTable[k].fullName)
		name:SetPos( 55, 5)
		name:SizeToContents()
		
		local amount = vgui.Create("DLabel", panel)
		amount:SetText("Amount:"..v)
		amount:SetPos( 55, 25)
		amount:SizeToContents()
		
		local weight = vgui.Create("DLabel", panel)
		weight:SetText("Weight:"..itemTable[k].weight.." lbs")
		weight:SetPos( 120, 25)
		weight:SizeToContents()
		
		local totalWeight = vgui.Create("DLabel", panel)
		totalWeight:SetText("Total Weight:"..itemTable[k].weight * v.." lbs")
		totalWeight:SetPos( 200, 25)
		totalWeight:SizeToContents()
	end
end

end;
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
[lua]
function DermaPanel:Think()
DermaPanel:InvalidateLayout()
end
[/lua]

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

Edit:

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

Yes.

http://www.facepunch.com/ads/rating/tick.png

YOU’RE BOTH HORRIBLE AT READING
/rage

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.

:ms:

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.