I can’t figure out why I need to put a panel:think in my code to get my dermapanel changing in real-time.
I have this in my code but I want to make the panel changing the size with a slider, any one can help me ?
[lua]function startframe() // the frame it will be set in.
local SizeNX = CreateClientConVar( “C_SizeX”, “0”, false, false)
local GetSizeX = SizeNX:GetInt()
local CAlpha = CreateClientConVar( “C_Alpha”, “1”, false, false)
local GetAlphaNo = CAlpha:GetFloat()
local WikiCount = 0
local DermaPanel = vgui.Create( “DFrame” ) – Creates the frame itself
DermaPanel:SetSize( GetSizeX + 210, 325 ) – Size of the frame ( use half the width / height of your screen )
DermaPanel:SetPos( 300, 100 )
local Size_X, Size_Y = DermaPanel:GetSize( ) – Get the size of the panel
local Title = “Size: (” … tostring( Size_X ) … ", " … tostring( Size_Y ) … “)” – Set our title in a variable
DermaPanel:SetTitle( Title ) – 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
DermaPanel.Paint = function()
draw.RoundedBox( 2, 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall(), Color( 100, 100, 100, 255 ) ) end
local NumSliderX = vgui.Create( “DNumSlider”, DermaPanel )
NumSliderX:SetPos( 25,50 )
NumSliderX:SetWide( 150 )
NumSliderX:SetText( “Set Size X” )
NumSliderX:SetMin( 0 ) – Minimum number of the slider
NumSliderX:SetMax( 512 ) – Maximum number of the slider
NumSliderX:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSliderX:SetConVar( “C_SizeX” ) – Set the convar
local NumSliderAlpha = vgui.Create( “DNumSlider”, DermaPanel )
NumSliderAlpha:SetPos( 25,150 )
NumSliderAlpha:SetWide( 150 )
NumSliderAlpha:SetText( “Set Alpha” )
NumSliderAlpha:SetMin( 0 ) – Minimum number of the slider
NumSliderAlpha:SetMax( 255 ) – Maximum number of the slider
NumSliderAlpha:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSliderAlpha:SetConVar( “C_Alpha” ) – Set the convar
local WikiLabel = vgui.Create(“DLabel”, DermaPanel)
WikiLabel:SetPos(35, 35)
WikiLabel:SetText(“Time: 0”)
WikiLabel:SizeToContents()
function DermaPanel:Think()
WikiCount = WikiCount + 0.05
WikiLabel:SetText("Time: "..WikiCount)
WikiLabel:SizeToContents()
end
end
concommand.Add(“MyTestPanel”,startframe,startframe)[/lua]