• How to get a value out of a registered vgui table?
    2 replies, posted
I'm trying to get a value out of a table using this- [CODE] local MenuBar = vgui.Create( "DPropertySheet", BasePanel ) //The base panel is not important here, it's just a DFrame anyway MenuBar:Dock(TOP) MenuBar:SetSize( 0, 200 ) local HomeOptionBase = {} function HomeOptionBase:Init() local HomeOptionColor = vgui.Create( "DColorMixer", self ) HomeOptionColor:Dock(LEFT) HomeOptionColor:SetPalette(true) HomeOptionColor:SetAlphaBar(true) HomeOptionColor:SetWangs(true) HomeOptionColor:SetColor(Color(30, 100, 160)) end local homeoptiontable = vgui.RegisterTable( HomeOptionBase, "DPanel" ) MenuBar:AddSheet( "Home", vgui.CreateFromTable( homeoptiontable ), nil, false, false, nil ) //There's some code here for some stuff that isn't important //Blah blah blah... thing:SetColor( HomeOptionColor:GetColor() ) [/CODE] The last bit, HomeOptionColor:GetColor does not work as HomeOptionColor is not registered outside the panel (I think). How should I be accessing this data?
You first want to make sure it still exists by putting that inside an [code]if IsValid(HomeOptionColor) then -Code here- end[/code] And the other thing is that the HomeOptionColor is a local variable inside the HomeOptionBase function, so it's only available inside it, you just have to remove the local from HomeOptionColor
Of course, I always miss the most obvious solution! Thanks!
Sorry, you need to Log In to post a reply to this thread.