1. Post #1

    February 2017
    5 Posts
    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.

  2. Post #2
    Heroezzz's Avatar
    May 2016
    64 Posts
    --

    Edited:

    It work!
    Code:
    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

  3. Post #3

    February 2017
    5 Posts
    Thanks Heroezzz, you save me.

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

    Thanks.

  4. Post #4
    Heroezzz's Avatar
    May 2016
    64 Posts
    Thanks Heroezzz, you save me.

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

    Thanks.
    Just
    Code:
    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

    Edited:

    Thanks Heroezzz, you save me.

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

    Thanks.
    If you have any problems, please contact me!

  5. Post #5

    February 2017
    5 Posts
    Pretty hard to understand because I'm beginner. But I will continue in aim to better understand.

    Edited:

    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 ?

  6. Post #6
    Heroezzz's Avatar
    May 2016
    64 Posts
    Pretty hard to understand because I'm beginner. But I will continue in aim to better understand.

    Edited:

    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

  7. Post #7

    February 2017
    5 Posts
    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

  8. Post #8
    Heroezzz's Avatar
    May 2016
    64 Posts
    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
    Code:
    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


    Example 2
    Code:
    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())

    Code:
    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

  9. Post #9

    February 2017
    5 Posts
    Ok, I understand but where is the directory for images ?

    Cordially.

  10. Post #10
    Heroezzz's Avatar
    May 2016
    64 Posts
    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\d ownload\materials