Bars
Dynamic progress bar creation and management system for the Lilia framework.
Overview
lia.bar.get(identifier)
Purpose
Retrieve a registered bar definition by its identifier.
When Called
Before updating/removing an existing bar or inspecting its state.
Parameters
string identifier optional Unique bar id supplied when added.
Returns
table|nil Stored bar data or nil if not found.
Example Usage
local staminaBar = lia.bar.get("stamina")
if staminaBar then
print("Current priority:", staminaBar.priority)
end
lia.bar.add(getValue, color, priority, identifier)
Purpose
Register a new dynamic bar with optional priority and identifier.
When Called
Client HUD setup or when creating temporary action/status bars.
Parameters
function getValue Returns current fraction (0-1) when called.
Color color optional Bar color; random bright color if nil.
number priority optional Lower draws earlier; defaults to append order.
string identifier optional Unique id; replaces existing bar with same id.
Returns
number Priority used for the bar.
Example Usage
-- Add a stamina bar that fades after inactivity.
lia.bar.add(function()
local client = LocalPlayer()
local stamina = client:getLocalVar("stm", 100)
return math.Clamp(stamina / 100, 0, 1)
end, Color(120, 200, 80), 2, "stamina")
lia.bar.remove(identifier)
Purpose
Remove a bar by its identifier.
When Called
After a timed action completes or when disabling a HUD element.
Parameters
string identifier Unique id passed during add.
Example Usage
timer.Simple(5, function() lia.bar.remove("stamina") end)
lia.bar.drawBar(pos, max, color)
Purpose
Draw a single bar at a position with given fill and color.
When Called
Internally from drawAll or for custom bars in panels.
Parameters
Example Usage
-- Custom panel painting a download progress bar.
function PANEL:Paint(w, h)
lia.bar.drawBar(10, h - 24, w - 20, 16, self.progress, 1, Color(120, 180, 255))
end