• Save DColorMixer color
    2 replies, posted
I'm in need of a way for the color chosen on a "DColorMixer" to be saved as the color of a, DFrame in this example. I've got it working to where when the frame is open, the mixer is shown on the panel. When I change the color on the mixer, the frame changes color to the one I chose. Then when I close the menu and reopen it, the color of the frame goes back to what the default color of the mixer is set to. So yea I need it to save the color when I close the menu so it will be the same. I read somewhere that I can do this with a table which, I'm not very good with :/
There should be an OnChanged / OnClick etc function that gets called. To save the color, use timer.Simple( 0, function( ) ... end ); where ... is where you store the new color into a variable in the scope of the file you modified / global / call a function with the new color. The reason timer 0 is because it has an issue with the small selectable squares where it won't take the color until the next frame. Edit: Found it: [code]function PANEL:ValueChanged( color )[/code] So:[code]local color = color_white; mymixer.ValueChanged = function( _color ) timer.Simple( 0, function( ) color = _color; end ); end[/code] or[code]local color = color_white; function mymixer:ValueChanged( _color ) timer.Simple( 0, function( ) color = _color; end ); end[/code] or[code]local color = color_white; function mymixer.ValueChanged( self, _color ) timer.Simple( 0, function( ) color = _color; end ); end[/code]
[QUOTE=Acecool;46041155]There should be an OnChanged / OnClick etc function that gets called. To save the color, use timer.Simple( 0, function( ) ... end ); where ... is where you store the new color into a variable in the scope of the file you modified / global / call a function with the new color. The reason timer 0 is because it has an issue with the small selectable squares where it won't take the color until the next frame. Edit: Found it: [code]function PANEL:ValueChanged( color )[/code] So:[code]local color = color_white; mymixer.ValueChanged = function( _color ) timer.Simple( 0, function( ) color = _color; end ); end[/code] or[code]local color = color_white; function mymixer:ValueChanged( _color ) timer.Simple( 0, function( ) color = _color; end ); end[/code] or[code]local color = color_white; function mymixer.ValueChanged( self, _color ) timer.Simple( 0, function( ) color = _color; end ); end[/code][/QUOTE] Was able to make it work. Much appreciated!
Sorry, you need to Log In to post a reply to this thread.