Debug Debug_menu
scripts/vscripts/alyxlib/debug/debug_menu.lua
Properties
version
Default value
"v1.0.0"
panel
Default value
nil
categories
Default value
table
Methods
UpdateMenuAttachment
Updates the physical menu by attaching it to the correct hand.
ShowMenu
Creates and displays the debug menu panel on the player's chosen hand.
CloseMenu
Closes the debug menu panel.
IsOpen
Returns whether the debug menu is currently open.
Returns
- boolean
True if the debug menu is open
ClickHoveredButton
Clicks the active button on the debug menu panel (the one highlighted by the finger).
This is handled automatically in most cases.
GetItem
Get a debug menu item by id.
Parameters
id
string
The item IDcategoryId(optional)
string
Optionally specify a category to look in. If not specified, will look in all categories
Returns
- DebugMenuItem?
The item if it exists
GetCategory
Get a debug menu category by id.
Parameters
id
string
The category ID
Returns
DebugMenuCategory?
The category if it exists
number?
The index of the category in the categories table
AddCategory
Add a category to the debug menu.
Parameters
id
string
The unique ID for this categoryname
string
The display name for this category
AddSeparator
Add a separator line to a category.
Parameters
categoryId
string
The category ID to add the separator toseparatorId(optional)
string
Optional ID for the separator if you want to modify it latertext(optional)
string
Optional title text to display on the separator
AddButton
Add a button to a category.
Parameters
categoryId
string
The category ID to add the button tobuttonId
string
The unique ID for this buttontext
string
The text to display on this buttoncommand
string,function
The console command or function to run when this button is pressed
AddToggle
Add a toggle to a category.
Parameters
categoryId
string
The category ID to add the toggle totoggleId
string
The unique ID for this toggletext
string
The text to display on this toggleconvar(optional)
string
The console variable tied to this togglecallback(optional)
function
Function to run when this toggle is toggledstartsOn(optional)
boolean,function
Whether the toggle is on by default
AddLabel
Add a center aligned label to a category.
Parameters
categoryId
string
The category ID to add the label tolabelId
string
The unique ID for this labeltext
string
The text to display on this label
AddSlider
Add value slider to a category.
DebugMenu:AddSlider(categoryId, sliderId, text, convar, min, max, isPercentage, truncate, increment, callback, defaultValue)
Parameters
categoryId
string
The ID of the category to add this slider tosliderId
string
A unique ID for this slidertext
string
Display text for the sliderconvar
string
The console variable to tie this slider tomin
number
Minimum allowed valuemax
number
Maximum allowed valueisPercentage
boolean
If true, value will be displayed as a percentage (0-100)truncate(optional)
number
Number of decimal places (0 = integer, -1 = no truncating)increment(optional)
number
Snap increment (0 disables snapping)callback(optional)
function
Callback functiondefaultValue(optional)
number,function
Starting value. Set nil to use the convar value whenever the menu opens
AddCycle
Add a value cycler to a category.
Cyclers allow users to choose from a set of values.
Parameters
categoryId
string
The id of the category to add this cycle tocycleId
string
The unique id for this new cycletitle
string,nil
The text to display next to each valueconvar(optional)
string
The console variable tied to this cyclevalues
{text:string,value:any}[],string[]
List of text/value pairs for this cycle, or a list of valuescallback(optional)
function
Function callbackdefaultValue(optional)
any,function
Value for this cycle to start with
SetItemText
Set the text of an item.
Only works on the following types:
-
button
-
toggle
-
slider
Parameters
categoryId
string
The ID of the category that contains the itemitemId
string
The ID of the item to modifytext
string
The new text
SetCategoryIndex
Sets the index of a category in the debug menu. Categories are ordered by their index, starting from 1.
This is an advanced function and should be used with caution.
Parameters
categoryId
string
Id of the category to change.index
number
New index for the category.
SendCategoryToPanel
Sends a category and all its elements to the panel.
This should only be used if modifying the menu in a non-standard way.
Parameters
category
DebugMenuCategory
The category to send
SendCategoriesToPanel
Forces the debug menu panel to add all categories and items.
This should only be used if modifying the menu in a non-standard way.
ClearMenu
Clears all categories and items from the debug menu panel.
Refresh
Forces the debug menu panel to refresh by removing and re-adding all categories and items.
SetItemVisibilityCondition
Sets the visibility condition for an item.
If the condition is not met when the menu opens, the item will not appear in the menu.
Parameters
categoryId
string
The category IDitemId
string
The item IDcondition
string,function
Convar name, function, ornilto remove the condition
StartListeningForMenuActivation
Starts listening for the debug menu activation button.
StopListeningForMenuActivation
Types
DebugMenuCategory
A category of items in the debug menu.
| Field | Type | Description |
|---|---|---|
| id | string |
The unique ID for this category. |
| name | string |
The display name for this category. |
| items | DebugMenuItem[] |
The items in this category. |
DebugMenuItem
An item in the debug menu.
| Field | Type | Description |
|---|---|---|
| categoryId | string |
The ID of the category this item is in. |
| id | string |
The unique ID for this item. |
| text | string |
The text to display for this item (if applicable). |
| callback | function |
The function to call when this item is clicked. |
| type | "button"|"toggle"|"separator"|"slider"|"cycle" |
Type of menu element this item is. |
| default | any|function |
The default value sent to the menu. If this is a function the return value will be used. |
| min | number |
Minimum value of this slider. |
| max | number |
Maxmimum value of this slider. |
| isPercentage | boolean |
If true, this slider displays its value as a percentage of min/max. |
| convar | string |
The console variable associated with this element. |
| values | {text:string,value:any}[] |
Text/value pairs for this cycler. |
| truncate | number |
The number of decimal places to truncate the slider value to (-1 for no truncating). |
| increment | number |
The increment value to snap the slider value to (0 for no snapping). |
| condition? | string|function |
The condition that must be met for this item to be visible. |