Derma_Install_Convar_Functions

From Garry's Mod
Jump to: navigation, search
 Derma_Install_Convar_Functions( )

Contents

Description

Makes the panel (usually an input of sorts) respond to changes in console variables by adding next functions to the panel:

The console variable value is saved in the m_strConVar property of the panel.

The panel should call Panel:ConVarStringThink or Panel:ConVarNumberThink in its PANEL:Think hook and should call Panel:ConVarChanged when the panel's value has changed.

Arguments

Panel target

The panel the functions should be added to.

Examples

Example

Adds the functions to a panel (snippet of vgui/dcheckbox.lua)

local PANEL = {}

Derma_Install_Convar_Functions( PANEL )

function PANEL:Init()
	-- Init function here
end
function PANEL:Think()
	self:ConVarStringThink()
end

Output:

The PANEL table now contains the functions SetConVar, ConVarChanged, ConVarStringThink and ConVarNumberThink (and an Init function and a Think function)
Personal tools
Navigation