I'm Trying to make a checkbox that will toggle Blur on my derma window, here is what i tried:
[lua]
function windowitself()
...
CheckBoxThing = vgui.Create( "DCheckBoxLabel", TehWindow )
CheckBoxThing:SetPos( 5, 5 )
CheckBoxThing:SetText( "Backround Blur Effect" )
CheckBoxThing:SizeToContents()
CheckBoxThing:SetConVar( "+ThunderCat_ToggleBlur" )
DermaList:AddItem( CheckBoxThing )
end
function ThunderCat_SetBlur()
TehWindow:SetBackgroundBlur( true )
end
function ThunderCat_DisableBlur()
TehWindow:SetBackgroundBlur( false )
end
concommand.Add( "+ThunderCat_ToggleBlur", ThunderCat_SetBlur )
concommand.Add( "-ThunderCat_ToggleBlur", ThunderCat_DisableBlur )[/lua]
and it didn't work. any help?
SetConVar doesn't work like that. It's set up so it calls '+ThunderCat_ToggleBlur [1/0]'. You need to hook into the value change function of the checkbox to get what you want.
[lua]function CheckBoxThing:OnChange( )
if ( self:GetValue( ) ) then
RunConsoleCommand( "+ThunderCat_ToggleBlur" )
else
RunConsoleCommand( "-ThunderCat_ToggleBlur" )
end
end[/lua]
[QUOTE=Overv;16998309][lua]function CheckBoxThing:OnChange( )
if ( self:GetValue( ) ) then
RunConsoleCommand( "+ThunderCat_ToggleBlur" )
else
RunConsoleCommand( "-ThunderCat_ToggleBlur" )
end
end[/lua][/QUOTE]
Toggle blur? i think it means no need for + and -, i'm right?
Yes there is, your + command enables it and - disables it. Actually get rid of that bullshit and just do this:
[lua]function CheckBoxThing:OnChange( )
TehWindow:SetBackgroundBlur( self:GetValue( ) )
end[/lua]
Like this?
[lua]
function windowitself()
...
CheckBoxThing = vgui.Create( "DCheckBoxLabel", DermaList )
CheckBoxThing:SetPos( 5, 5 )
CheckBoxThing:SetText( "Backround Blur Effect" )
CheckBoxThing:SizeToContents()
DermaList:AddItem( CheckBoxThing )
CheckBoxThing:SetValue( true )
end
function CheckBoxThing:OnChange( )
TehWindow:SetBackgroundBlur( self:GetValue( ) )
end[/lua]
doesn't work :(.
[lua]function CheckBoxThing:OnChange( val )
TehWindow:SetBackgroundBlur( val )
end[/lua]
If that doesn't work, could you post the full code?
[QUOTE=Overv;17000330][lua]function CheckBoxThing:OnChange( val )
TehWindow:SetBackgroundBlur( val )
end[/lua]
If that doesn't work, could you post the full code?[/QUOTE]
I pm'd it for you.
Nevermind, I'll look at it later.
Sorry, you need to Log In to post a reply to this thread.