Creating new status for HUD

In order to create new status, let's start from going to /shared/ui_cfg/config_hud.lua

Creating status

We will do example with hygiene (without doing the backend to status). Here we need to add new element for the interface:

Config.Hud.Status['hygiene'] = { -- key value
    name = 'hygiene', -- unique name of status, set it as the key value above
    icon = 'fas fa-soap', -- set icon for the status
    value = 0, -- do not change
    isVisible = true, -- do not change
}

Settings status order

Status order is basically setting the order of elements on screen. It's crucial to made this change. In the same file find:

Config.Hud.Order = {
    'health', 'armour', 'hunger', 'thirst'
}

And add your previously created status key:

Config.Hud.Order = {
    'health', 'armour', 'hunger', 'thirst', 'hygiene'
}

Connecting status

If you already done backend for the status to gather and handle the values, go to /client/addon/status.lua . Here's the whole handler to dynamically set values.

So let's go. To properly connect status we need to get the values, we will create pseudo-export and make sure you replace it with yours.

Add the following code above:

--[[
    Misc code below.
]]

Code to add:

Config.Hud.Status['hygiene'].get = function()
    return exports['my_resource']:MyPseudoFunctionForHygiene()
end

Last updated