Skip to content

Menu

Clientside helpers for world-anchored interaction menus.


Overview

The menu library manages temporary clientside option menus under `lia.menu`. Menus are anchored to either a world position or an entity-local position, drawn near their projected screen position, faded based on range and crosshair focus, and resolved into callbacks when the active option is selected.

lia.menu.add(opts, pos, onRemove)View Source

Purpose

Adds a temporary clientside menu using the provided option table and anchor position.

Realm

Client

Parameters

table opts A table where each key is the label displayed in the menu and each value is the callback or payload associated with that option.

Vector|Entity pos optional The world position used to anchor the menu. If an entity is provided, the current eye trace hit position is stored relative to that entity. If nil, the local player's current eye trace hit position is used.

function onRemove optional Optional function called with the menu data as self when the menu is automatically removed during drawing.

Returns

number The index of the inserted menu entry in `lia.menu.list`.

Example Usage

  lia.menu.add({
      Search = function() print("search") end,
      Unlock = function() print("unlock") end
  })

lia.menu.drawAll()View Source

Purpose

Draws every active menu, updates fade state, highlights the option under the screen center, and removes expired or invalid entries.

Realm

Client

Example Usage

  hook.Add("HUDPaint", "liaMenuDrawAll", function()
      lia.menu.drawAll()
  end)

lia.menu.getActiveMenu()View Source

Purpose

Gets the menu option currently targeted by the screen center while the local player is within interaction distance.

Realm

Client

Returns

number|nil The active menu index, or nil if no menu option is active. any|nil The callback or payload associated with the active option, or nil if no menu option is active.

Example Usage

  local id, callback = lia.menu.getActiveMenu()
  if id then lia.menu.onButtonPressed(id, callback) end

lia.menu.onButtonPressed(id, cb)View Source

Purpose

Removes a menu entry and runs the selected option callback when one is provided.

Realm

Client

Parameters

number id The menu index to remove from `lia.menu.list`.

function cb optional Optional callback to run after the menu entry is removed.

Returns

boolean True if a callback was provided and executed, otherwise false.

Example Usage

  local id, callback = lia.menu.getActiveMenu()
  if id then
      lia.menu.onButtonPressed(id, callback)
  end