Action with a button doesn't work

Hi everyone,

Today, I would like to make a button which is able to be enabled only if the checkbox have been checked before.
This is my code (it not working):

local checkcl = vgui.Create( “DCheckBoxLabel”, Panel )
checkcl:SetPos( 25, 265 )
checkcl:SetText( “I confirm that I am over 16 years of age” )
checkcl:SizeToContents()
function checkcl:GetChecked( var )
if ( IsValid(var)) then
Button:SetEnabled( true )
else
Button:SetEnabled( false )
end
end

local Button = vgui.Create( “DButton” , Panel)
Button:SetPos(250, 295)
Button:SetSize( 100, 50 )
Button:SetText( “Validate” )
Button.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, 0, 0, Color( 0, 0, 153, 250 ) )
end
Button.DoClick = function( )
Panel:Close()
end

Thanks.

[editline]17th February 2017[/editline]

It work!


local Panel = vgui.Create( "DFrame" )
Panel:SetPos( 100, 100 )
Panel:SetSize( 300, 200 )
Panel:SetTitle( "My new Derma frame" )
Panel:SetDraggable( true )
Panel:MakePopup()


local checkcl = vgui.Create( "DCheckBoxLabel", Panel ) 
checkcl:SetPos( 25, 10 )	
checkcl:SetText( "I confirm that I am over 16 years of age" )	
checkcl:SizeToContents()

	





local Button = vgui.Create( "DButton" , Panel)
Button:SetPos(250, 60)
Button:SetSize( 100, 50 )
Button:SetText( "Validate" )


Button.DoClick = function( )
        
end



function checkcl:Think()
if checkcl:GetChecked() == true then
            Button:SetEnabled( true )
            else
Button:SetEnabled( false )
end
end

Thanks Heroezzz, you save me.

But can you explain me why you use Think(), and what it mean ?

Thanks.

Just


function checkcl:GetChecked( var )

function takes only true and false and can not be used as a variable! because it only takes labor and Fals and could not be used for functions
аA function to think speaks for itself! She thinks! Just read it
GetChecked and Think

[editline]17th February 2017[/editline]

If you have any problems, please contact me!

Pretty hard to understand because I’m beginner. But I will continue in aim to better understand.

[editline]17th February 2017[/editline]

If I understood correctly, you will mean that the thing that I want to do need to have Think because this function have a choice True or False. But is the function can work without Think ?

The function is often used to think, but you need to know what features are valid values ​​if, else, else if

Hi sorry,
But i’ve an another question just to know how can i import a custom picture in game which is button after? I’ve seen how can i make a button with picture but i don’t know where i put the pictures.

Cordially


local DermaBtn = vgui.Create( "DButton",DermaPanel )
DermaBtn:SetPos( DermaPanel:GetTall() + 70 , 10 )
DermaBtn:SetSize( 20, 20 )
DermaBtn:SetText( "" )
function DermaBtn:Paint(w,h)
    surface.SetDrawColor(Color(255,255,255))
    surface.SetMaterial( Material("icon16/cancel.png" ))
	surface.DrawTexturedRect(0,0,16,16)
end

	DermaBtn.DoClick = function()
		DermaPanel:Close()
	end

http://i12.pixs.ru/storage/3/8/2/3jpg_8259385_25211382.jpg

Example 2


local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 450, 200 )
DermaPanel:SetSize( 400, 300 )
DermaPanel:SetTitle( "My new Derma frame" )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton(false)
DermaPanel:MakePopup()

local fka = vgui.Create("DImage", DermaPanel)
	fka:SetImage("backgrounds/caste_nostalgia.jpg")
	fka:SetPos(0, 0)
	fka:SetSize(ScrW(), ScrH())

http://i12.pixs.ru/storage/4/0/1/4jpg_1719120_25211401.jpg



local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 450, 200 )
DermaPanel:SetSize( 400, 300 )
DermaPanel:SetTitle( "My new Derma frame" )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton(false)
DermaPanel:MakePopup()
function DermaPanel:Paint(w,h)

	draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 115 ) )
    surface.SetDrawColor(Color(255,255,255)) -- Color img
    surface.SetMaterial( Material("icon16/user.png" ))
	surface.DrawTexturedRect(20,20,16,16) -- (x pos,y pos,size x,size y)
end

http://i12.pixs.ru/storage/4/2/1/5jpg_8305374_25211421.jpg

Ok, I understand but where is the directory for images ?

Cordially.

You can yourself upload in:
C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\download\materials