I am trying to create a command that when run will open a certain submodule in the client settings. My latest attempt was to just copy+paste the code of the function that is called when a row is selected, but I get the same error as with previous tries:
[ERROR] addons/ulx/lua/ulx/modules/cl/xlib.lua:1113: attempt to index field 'panel' (a nil value)
I assume this is because I am setting nPanel to the wrong thing. I have tried the name of a submodule ("General Settings") and the acutal panel (genpnl) but neither seem to work.
Here is the function I copy+pasted, it is in addons/ulx/lua/ulx/xgui/settings/client.lua:
function changeClientSettingsTab( nPanel )
if nPanel ~= client.curPanel then
nPanel:SetZPos( 0 )
xlib.addToAnimQueue( "pnlSlide", { panel=nPanel, startx=-435, starty=0, endx=0, endy=0, setvisible=true } )
if client.curPanel then
client.curPanel:SetZPos( -1 )
xlib.addToAnimQueue( client.curPanel.SetVisible, client.curPanel, false )
end
xlib.animQueue_start()
client.curPanel = nPanel
else
xlib.addToAnimQueue( "pnlSlide", { panel=nPanel, startx=0, starty=0, endx=-435, endy=0, setvisible=false } )
self:ClearSelection()
client.curPanel = nil
xlib.animQueue_start()
end
if nPanel.onOpen then nPanel.onOpen() end --If the panel has it, call a function when it's opened
end
And here is the code where I call that function, located in addons/ulx/lua/ulx/modules/cl/xgui_client.lua:
ULib.cmds.addCommandClient( "ulx opentab", function( ply, cmd, args )
xgui.show( "client" )
changeClientSettingsTab( genpnl )
end )
Any help is appreciated!