Garry's Mod Wiki

spawnmenu

The spawnmenu library is a set of functions that allow you to control the spawn (Q) menu.

Methods

spawnmenu.ActivateTool( string tool, boolean menu_only = false )
Activates a tool, opens context menu and brings up the tool gun.
spawnmenu.ActivateToolPanel( number tab, Panel cp )
Activates tools context menu in specified tool tab.
Returns currently opened control panel of a tool, post process effect or some other menu in spawnmenu.
spawnmenu.AddContentType( string name, function constructor )
Registers a new content type that is saveable into spawnlists. Created/called by spawnmenu. CreateContentIcon.
spawnmenu.AddCreationTab( string name, function function, string material = "icon16/exclamation.png", number order = 1000, string tooltip = "nil" )
Inserts a new tab into the CreationMenus table, which will be used by the creation menu to generate its tabs (Spawnlists, Weapons, Entities, etc. )
spawnmenu.AddPropCategory( string classname, string name, table contents, string icon, number id = 1000, number parentID = 0, string needsApp = "" )
Used to add addon spawnlists to the spawnmenu tree. This function should be called within SANDBOX:PopulatePropMenu. Addon spawnlists will not save to disk if edited. You should never try to modify player customized spawnlists!
spawnmenu.AddToolCategory( string tab, string RealName, string PrintName )
Used to create a new category in the list inside of a spawnmenu ToolTab. You must call this function from SANDBOX:AddToolMenuCategories for it to work properly.
spawnmenu.AddToolMenuOption( string tab, string category, string class, string name, string cmd, string config, function cpanel, table table = {} )
Adds an option to the right side of the spawnmenu
spawnmenu.AddToolTab( string name, string label = "name", string icon = "icon16/wrench.png" )
Adds a new tool tab to the right side of the spawnmenu via the SANDBOX:AddToolMenuTabs hook. This function is a inferior duplicate of spawnmenu. GetToolMenu, just without its return value.
spawnmenu.ClearToolMenus()
Clears all the tools from the different tool categories and the categories itself, if ran at the correct place. Seems to only work when ran at initialization.
Panel spawnmenu.CreateContentIcon( string type, Panel parent = nil, table data )
Creates a new content icon.
spawnmenu.DoSaveToTextFiles( table spawnlists )
This is used internally - although you're able to use it you probably shouldn't. Calls spawnmenu. SaveToTextFiles.
function spawnmenu.GetContentType( string contentType )
Returns the function to create an vgui element for a specified content type
Returns the list of Creation tabs. Creation tabs are added via spawnmenu. AddCreationTab.
Similar to spawnmenu. GetPropTable, but only returns spawnlists created by addons via spawnmenu. AddPropCategory. These spawnlists are shown in a separate menu in-game.
table spawnmenu.GetPropTable()
Returns a table of all prop categories and their props in the spawnmenu. Note that if the spawnmenu has not been populated, this will return an empty table. This will not return spawnlists created by addons, see spawnmenu. GetCustomPropTable for that.
table spawnmenu.GetToolMenu( string name, string label = "name", string icon = "icon16/wrench.png" )
Adds a new tool tab (or returns an existing one by name) to the right side of the spawnmenu via the SANDBOX:AddToolMenuTabs hook.
table spawnmenu.GetTools()
Gets a table of tools on the client.
This is used internally - although you're able to use it you probably shouldn't. Calls spawnmenu. PopulateFromTextFiles.
spawnmenu.PopulateFromTextFiles( function callback )
This is used internally - although you're able to use it you probably shouldn't. Loads spawnlists from text files. You probably are looking for spawnmenu. AddPropCategory.
spawnmenu.SaveToTextFiles( table spawnlists )
This is used internally - although you're able to use it you probably shouldn't. Saves a table of spawnlists to files.
spawnmenu.SetActiveControlPanel( Panel pnl )
This is used internally - although you're able to use it you probably shouldn't. Sets currently active control panel to be returned by spawnmenu. ActiveControlPanel.
spawnmenu.SwitchCreationTab( string id )
Switches the creation tab (left side of the spawnmenu) on the spawnmenu to the given tab.
spawnmenu.SwitchToolTab( number id )
Opens specified tool tab in spawnmenu.