Skip to content

Bar

HUD bar helpers for registering, retrieving, removing, drawing, and displaying temporary action progress bars.


Overview

The bar library centralizes clientside HUD bar behavior under `lia.bar`. It manages registered status bars, smooths value changes over time, controls visibility through options and hooks, draws bar panels, and provides a temporary action progress bar panel for timed clientside actions.

lia.bar.get(identifier)View Source

Purpose

Gets a registered HUD bar by its identifier.

Realm

Client

Parameters

string identifier The unique identifier assigned when the bar was registered.

Returns

table The registered bar data, or nil if no matching bar exists.

Example Usage

  local bar = lia.bar.get("health")
  if bar then print(bar.priority) end

lia.bar.add(getValue, color, priority, identifier)View Source

Purpose

Registers a HUD bar and replaces an existing bar when the same identifier is provided.

Realm

Client

Parameters

function getValue Function that returns the bar's current normalized value.

Color color The color used to draw the bar fill. If omitted, a random bright color is used.

number priority The sort priority used when drawing bars. Lower values draw first. If omitted, the next list position is used.

string identifier Optional unique identifier used to retrieve, replace, or remove the bar later.

Returns

number The priority assigned to the registered bar.

Example Usage

  lia.bar.add(function()
      return LocalPlayer():Health() / LocalPlayer():GetMaxHealth()
  end, Color(200, 50, 40), 1, "health")

lia.bar.remove(identifier)View Source

Purpose

Removes a registered HUD bar by its identifier.

Realm

Client

Parameters

string identifier The unique identifier of the bar to remove.

Example Usage

  lia.bar.remove("stamina")

lia.bar.drawBar(x, y, w, h, pos, max, color)View Source

Purpose

Draws a single HUD bar panel and its filled portion.

Realm

Client

Parameters

number x The horizontal screen position.

number y The vertical screen position.

number w The bar width.

number h The bar height.

number pos The current bar value.

number max The maximum bar value.

Color color The color used to draw the filled portion.

Example Usage

  lia.bar.drawBar(4, 4, ScrW() * 0.35, 18, 0.75, 1, Color(200, 50, 40))

lia.bar.drawAction(text, duration)View Source

Purpose

Displays a temporary action progress bar with text and a countdown duration.

Realm

Client

Parameters

string text The text displayed on the action progress bar.

number duration The duration, in seconds, before the action progress bar is removed.

Example Usage

  lia.bar.drawAction("Searching...", 5)

lia.bar.drawAll()View Source

Purpose

Draws every registered HUD bar that should currently be visible.

Realm

Client

Example Usage

  hook.Add("HUDPaintBackground", "liaBarDraw", lia.bar.drawAll)

Hooks

Library-specific hooks documented for this library.


ShouldBarDraw(bar)View Source

Purpose

Allows plugins or modules to force a specific registered HUD bar to draw even when it would not otherwise be visible.

Realm

Client

Parameters

table bar The registered bar data currently being evaluated for drawing.

Returns

boolean|nil Return true to draw the bar. Return nil or false to continue normal visibility behavior.


ShouldHideBars()View Source

Purpose

Allows plugins or modules to hide all registered HUD bars before they are drawn.

Realm

Client

Returns

boolean|nil Return true to stop all HUD bars from drawing. Return nil or false to allow normal drawing checks to continue.