HUD bars: horizontal progress bars such as a respawn timer or a "getting up" timer. A bar is a table of settings registered under an ID with Flux.Bars:register: its text, color, value and maximum, position and size, and optionally a callback that returns its current value. The type of a bar decides how it is laid out. BAR_TOP bars are stacked from the top left corner of the screen in order of their priority and are drawn together by Flux.Bars:DrawTopBars, which the gamemode calls while it paints the HUD of a living player. Bars of the other types (BAR_MANUAL, BAR_HIDDEN) keep the position they were registered with and are drawn by their owner with Flux.Bars:draw, usually from a HUD paint hook.

Every LazyTick the top bars are repositioned and the bars that have a callback get their value refreshed; other bars are updated with Flux.Bars:set_value, which animates the fill toward the new value. Part of a bar can be blocked off with Flux.Bars:hinder_value. A bar is only drawn while its value is inside its display range (above min_display and not above display). The drawing itself is done by the active theme through the DrawBarBackground, DrawBarFill, DrawBarHindrance and DrawBarTexts theme hooks, and plugins can step in with the bar hooks (ShouldDrawBar, PreDrawBar, AdjustBarPos, AdjustBarInfo and so on).

Summary

Methods

Merges the specified settings into an existing bar.
draw(id)client
Draws the bar with the specified ID using the active theme.
Draws every bar from the prioritized list of top bars.
get(id)client
Returns the bar registered under the specified ID.
Sets the hindrance value of a bar (the part of it that is blocked off), clamped between 0 and its max value.
Recalculates the positions of all top bars, stacking them vertically in order of priority.
Rebuilds the list of top bars grouped by priority.
Registers a HUD bar.
Sets the value of a bar, clamped between 0 and its max value, and starts the fill animation toward it.

Methods

Flux.Bars:adjust(id, data)

client packages/active_ui/lib/cl_bars.lua:305

Merges the specified settings into an existing bar.

Parameters

  • id String bar ID
  • data Map bar settings to overwrite, same keys as in Flux.Bars#register

Flux.Bars:draw(id)

client packages/active_ui/lib/cl_bars.lua:242

Draws the bar with the specified ID using the active theme. Does nothing if the bar does not exist or the 'ShouldDrawBar' hook returns false for it.

Parameters

  • id String bar ID

Flux.Bars:DrawTopBars()

client packages/active_ui/lib/cl_bars.lua:292

Draws every bar from the prioritized list of top bars. The gamemode calls it every frame while it paints the HUD of a living player, along with the info displays.

Flux.Bars:get(id)

client packages/active_ui/lib/cl_bars.lua:119

Returns the bar registered under the specified ID.

Parameters

  • id String bar ID

Returns

  • Map the bar, or false if it does not exist

Flux.Bars:hinder_value(id, new_value)

client packages/active_ui/lib/cl_bars.lua:155

Sets the hindrance value of a bar (the part of it that is blocked off), clamped between 0 and its max value. Calls the 'PreBarHinderValueSet' theme hook first.

Parameters

  • id String bar ID
  • new_value Number

Flux.Bars:position()

client packages/active_ui/lib/cl_bars.lua:206

Recalculates the positions of all top bars, stacking them vertically in order of priority. Plugins can offset each bar through the 'AdjustBarPos' hook.

Flux.Bars:prioritize()

client packages/active_ui/lib/cl_bars.lua:170

Rebuilds the list of top bars grouped by priority. Bars that the 'ShouldDrawBar' hook returns false for are left out.

Returns

  • Map priority mapped to a List<String> of bar IDs

Flux.Bars:register(id, data, force)

client packages/active_ui/lib/cl_bars.lua:71

Registers a HUD bar. If a bar with this ID already exists it is returned untouched, unless force is set or Flux runs in development mode. The width, height, spacing, text offset and corner radius are given for a 1080p screen and scaled to the current one; the position is in actual screen pixels.

Flux.Bars:register('getup', {
  text = t'ui.hud.bar_text.getup',
  color = Color(50, 200, 50),
  max_value = 100,
  x = ScrW() * 0.5 - Flux.Bars.default_w * 0.5,
  y = ScrH() * 0.5 - math.scale(8),
  height = 20,
  type = BAR_MANUAL
})

Parameters

  • id String unique bar ID
  • data Map bar settings such as text, color, value, max_value, x, y, width, height, priority, type (BAR_TOP, BAR_MANUAL or BAR_HIDDEN), font and callback (receives the bar, returns its new value); missing keys get defaults
  • force Boolean optional, defaults to false overwrite an existing bar with the same ID

Returns

  • Map the stored bar, or nil if no data was given

Flux.Bars:set_value(id, new_value)

client packages/active_ui/lib/cl_bars.lua:131

Sets the value of a bar, clamped between 0 and its max value, and starts the fill animation toward it. Calls the 'PreBarValueSet' theme hook first.

Parameters

  • id String bar ID
  • new_value Number

Defined in