• DRGBPicker, DLabel, and DColorCube Trouble
    4 replies, posted
So when I change the color either DColorCube it changes only one DLabel. Here are the snips of the code that will be needed, but if you need more I will be sure to give it to you. Im not sure why its doing this. [CODE]local SERVER_Label = vgui.Create( "DLabel", SMSG ) SERVER_Label:SetPos( 14, 95 ) SERVER_Label:SetSize( 211, 26 ) SERVER_Label:SetText( SERVERNAME:GetValue() ) local MESSAG_Label = vgui.Create( "DLabel", SMSG ) MESSAG_Label:SetPos( 14, 250 ) MESSAG_Label:SetSize( 211, 26 ) MESSAG_Label:SetText( MESSAG:GetValue() ) -- Color picker local picker_pilltext = vgui.Create( "DRGBPicker", SMSG ) picker_pilltext:SetPos( 240, 45 ) picker_pilltext:SetSize( 35, 150 ) -- Color cube local cube_ctex = vgui.Create( "DColorCube", SMSG ) cube_ctex:SetPos( 280, 45 ) cube_ctex:SetSize( 155, 150 ) ----------------------NOPE NOEP NOPE 2 DIFFERENT THINGS BELOW IS BELOW UP TOP IS UP TOP local picker_pilltextB = vgui.Create( "DRGBPicker", SMSG ) picker_pilltextB:SetPos( 240, 220 ) picker_pilltextB:SetSize( 35, 150 ) -- Color cube local cube_ctexB = vgui.Create( "DColorCube", SMSG ) cube_ctexB:SetPos( 280, 220 ) cube_ctexB:SetSize( 155, 150 ) -- When the piller is changed so does the cube -- function picker_pilltextB:OnChange( col ) -- Get the stuff.. yea. local h = ColorToHSV( col ) local _, s, v = ColorToHSV( cube_ctexB:GetRGB() ) -- Lets just be freinds and combine them? col = HSVToColor( h, s, v ) cube_ctexB:SetColor( col ) end function picker_pilltext:OnChange( coll ) -- Get the stuff.. yea. local h = ColorToHSV( coll ) local _, s, v = ColorToHSV( cube_ctex:GetRGB() ) -- Lets just be freinds and combine them? coll = HSVToColor( h, s, v ) cube_ctex:SetColor( coll ) end --------------------Community Name Color---------------- function cube_ctexB:OnUserChanged( col ) -- Update background color and label UpdateColors( col ) end -- Updates display colors, label, and clipboard text function UpdateColors( col ) SERVER_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end -------------------------------Server Message Color---------------------------- function cube_ctex:OnUserChanged( col ) -- Update background color and label UpdateColors( col ) end -- Updates display colors, label, and clipboard text function UpdateColors( col ) MESSAG_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end[/CODE]
[CODE] function UpdateColors( col ) SERVER_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end -- Updates display colors, label, and clipboard text function UpdateColors( col ) MESSAG_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end [/CODE] You overwrote the function. Of course it's only going to change one label. [CODE] -- Updates display colors, label, and clipboard text function UpdateColors( col ) SERVER_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) MESSAG_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end [/CODE] [editline]23rd July 2017[/editline] Also, please make that function local
[QUOTE=MPan1;52498865][CODE] function UpdateColors( col ) SERVER_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end -- Updates display colors, label, and clipboard text function UpdateColors( col ) MESSAG_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end [/CODE] You overwrote the function. Of course it's only going to change one label. [CODE] -- Updates display colors, label, and clipboard text function UpdateColors( col ) SERVER_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) MESSAG_Label:SetColor( Color( ( col.r ), ( col.g ), ( col.b ) ) ) end [/CODE] [editline]23rd July 2017[/editline] Also, please make that function local[/QUOTE] That just makes both of the labels the same color. Im trying to make one change the label that it is told to change
Can't you just do [CODE] function cube_ctexB:OnUserChanged( col ) MESSAG_Label:SetColor( col ) end function cube_ctex:OnUserChanged( col ) SERVER_Label:SetColor( col ) end [/CODE]
[QUOTE=MPan1;52498899]Can't you just do [CODE] function cube_ctexB:OnUserChanged( col ) MESSAG_Label:SetColor( col ) end function cube_ctex:OnUserChanged( col ) SERVER_Label:SetColor( col ) end [/CODE][/QUOTE] Thanks a lot that worked. I was just doing a lot of overwriting in that mess. :D Thanks dude!
Sorry, you need to Log In to post a reply to this thread.