Garry's Mod Wiki

Revision Difference

Custom_SpawnMenu#526925

<cat>Dev.Lua</cat>⤶ <title>Custom SpawnMenu</title>⤶ ⤶ # How do I make my own SpawnMenu?⤶ ⤶ ## This requires, at a minimum, accessing all added tabs. You can do this like this:⤶ ⤶ ```lua⤶ for k, v in SortedPairsByMemberValue( spawnmenu.GetCreationTabs(), 'Order' ) do⤶ PrintTable( v )⤶ ⤶ print( k ) -- The tab name⤶ end⤶ ```⤶ ⤶ ## Next you need to access the Tool part:⤶ ⤶ ```lua⤶ for k, v in pairs( spawnmenu.GetTools() ) do⤶ for a, b in pairs( v ) do⤶ if ( istable( b ) ) then⤶ for l, p in pairs( b ) do⤶ print( p.Text ) -- Category name⤶ ⤶ for g, h in pairs( p ) do⤶ if ( istable( h ) ) then⤶ print( h.Text ) -- Name of the tool itself⤶ end⤶ end⤶ end⤶ end⤶ end⤶ end⤶ ```⤶ ⤶ The most difficult thing has already been done, it remains only to substitute the VGUI part to these schemes and enjoy your SpawnMenu.⤶ ⤶ # Example of a ready-made SpawnMenu⤶ ⤶ ## SpawnMenu by Freline user:⤶ https://steamcommunity.com/sharedfiles/filedetails/?id=2032678386