Skip to content

Debug Debug_menu

scripts/vscripts/alyxlib/debug/debug_menu.lua

Properties

version

DebugMenu.version = value

Default value "v1.0.0"

panel

DebugMenu.panel = value

Default value nil

categories

DebugMenu.categories = value

Default value table

Methods

UpdateMenuAttachment

Updates the physical menu by attaching it to the correct hand.

DebugMenu:UpdateMenuAttachment()

ShowMenu

Creates and displays the debug menu panel on the player's chosen hand.

DebugMenu:ShowMenu()

CloseMenu

Closes the debug menu panel.

DebugMenu:CloseMenu()

IsOpen

Returns whether the debug menu is currently open.

DebugMenu:IsOpen()

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.

DebugMenu:ClickHoveredButton()

GetItem

Get a debug menu item by id.

DebugMenu:GetItem(id, categoryId)

Parameters

  • id
    string
    The item ID
  • categoryId (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.

DebugMenu:GetCategory(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.

DebugMenu:AddCategory(id, name)

Parameters

  • id
    string
    The unique ID for this category
  • name
    string
    The display name for this category

AddSeparator

Add a separator line to a category.

DebugMenu:AddSeparator(categoryId, separatorId, text)

Parameters

  • categoryId
    string
    The category ID to add the separator to
  • separatorId (optional)
    string
    Optional ID for the separator if you want to modify it later
  • text (optional)
    string
    Optional title text to display on the separator

AddButton

Add a button to a category.

DebugMenu:AddButton(categoryId, buttonId, text, command)

Parameters

  • categoryId
    string
    The category ID to add the button to
  • buttonId
    string
    The unique ID for this button
  • text
    string
    The text to display on this button
  • command
    string, function
    The console command or function to run when this button is pressed

AddToggle

Add a toggle to a category.

DebugMenu:AddToggle(categoryId, toggleId, text, convar, callback, startsOn)

Parameters

  • categoryId
    string
    The category ID to add the toggle to
  • toggleId
    string
    The unique ID for this toggle
  • text
    string
    The text to display on this toggle
  • convar (optional)
    string
    The console variable tied to this toggle
  • callback (optional)
    function
    Function to run when this toggle is toggled
  • startsOn (optional)
    boolean, function
    Whether the toggle is on by default

AddLabel

Add a center aligned label to a category.

DebugMenu:AddLabel(categoryId, labelId, text)

Parameters

  • categoryId
    string
    The category ID to add the label to
  • labelId
    string
    The unique ID for this label
  • text
    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 to
  • sliderId
    string
    A unique ID for this slider
  • text
    string
    Display text for the slider
  • convar
    string
    The console variable to tie this slider to
  • min
    number
    Minimum allowed value
  • max
    number
    Maximum allowed value
  • isPercentage
    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 function
  • defaultValue (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.

DebugMenu:AddCycle(categoryId, cycleId, title, convar, values, callback, defaultValue)

Parameters

  • categoryId
    string
    The id of the category to add this cycle to
  • cycleId
    string
    The unique id for this new cycle
  • title
    string, nil
    The text to display next to each value
  • convar (optional)
    string
    The console variable tied to this cycle
  • values
    {text:string,value:any}[], string[]
    List of text/value pairs for this cycle, or a list of values
  • callback (optional)
    function
    Function callback
  • defaultValue (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

DebugMenu:SetItemText(categoryId, itemId, text)

Parameters

  • categoryId
    string
    The ID of the category that contains the item
  • itemId
    string
    The ID of the item to modify
  • text
    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.

DebugMenu:SetCategoryIndex(categoryId, index)

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.

DebugMenu:SendCategoryToPanel(category)

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.

DebugMenu:SendCategoriesToPanel()

ClearMenu

Clears all categories and items from the debug menu panel.

DebugMenu:ClearMenu()

Refresh

Forces the debug menu panel to refresh by removing and re-adding all categories and items.

DebugMenu:Refresh()

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.

DebugMenu:SetItemVisibilityCondition(categoryId, itemId, condition)

Parameters

  • categoryId
    string
    The category ID
  • itemId
    string
    The item ID
  • condition
    string, function
    Convar name, function, or nil to remove the condition

StartListeningForMenuActivation

Starts listening for the debug menu activation button.

DebugMenu:StartListeningForMenuActivation()

StopListeningForMenuActivation

DebugMenu: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.