hud.setFieldColor 2
Sets the colour of a field's value text. Components go from 0 to 1 and are clamped. Creates the field if it does not exist yet.
Return value
| Return Type | Description |
|---|---|
| void | This function doesn't return anything |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | string | Identifier of the field to colour. |
| 2 | float | Red component, from 0 to 1. |
| 3 | float | Green component, from 0 to 1. |
| 4 | float | Blue component, from 0 to 1. |
| 5 | float | Alpha, from 0 to 1. Optional, defaults to 1. |
Examples
Custom conquer bar
-- Replace the vanilla conquer bar with two fields of our own.
-- Runs on every client: no network sync needed.
hud.setVanillaBar(false) -- hide flags, tickets and capture squares
hud.setPhases(false) -- this mission does not advance through phases
local wave = 1
local left = 12
local function refresh()
hud.setField("wave", "hud_icon_wave", "Wave " .. wave)
hud.setField("enemies", "hud_icon_enemy", tostring(left))
-- keep the counter from making the bar jump as digits change
hud.setFieldWidth("enemies", 60)
-- turn the counter red when the position is about to fall
if left <= 3 then
hud.setFieldColor("enemies", 1, 0.35, 0.35)
else
hud.setFieldColor("enemies", 1, 1, 1)
end
end
refresh()