Attributes Library
Character attribute management system for the Lilia framework.
Overview
The attributes library provides functionality for managing character attributes in the Lilia framework. It handles loading attribute definitions from files, registering attributes in the system, and setting up attributes for characters during spawn. The library operates on both server and client sides, with the server managing attribute setup during character spawning and the client handling attribute-related UI elements. It includes automatic attribute loading from directories, localization support for attribute names and descriptions, and hooks for custom attribute behavior.
lia.attribs.loadFromDir(directory)
Discover and include attribute definitions from a directory.
During schema/gamemode startup to load all attribute files.
Parameters:
string directory Path containing attribute Lua files.Example Usage:
-- Load default and custom attributes.
lia.attribs.loadFromDir(lia.plugin.getDir() .. "/attribs")
lia.attribs.loadFromDir("schema/attribs")
lia.attribs.register(uniqueID, data)
Register or update an attribute definition in the global list.
After loading an attribute file or when hot-reloading attributes.
Parameters:
string uniqueID Attribute key.table data Fields like name, desc, OnSetup, setup, etc.
Returns:
table The stored attribute table.Example Usage:
lia.attribs.register("strength", {
name = "Strength",
desc = "Improves melee damage and carry weight.",
OnSetup = function(client, value)
client:SetJumpPower(160 + value * 0.5)
end
})
lia.attribs.setup(client)
Run attribute setup logic for a character on the server.
On player spawn/character load to reapply attribute effects.
Parameters:
Player client Player whose character attributes are being applied.Example Usage:
hook.Add("PlayerLoadedChar", "ApplyAttributeBonuses", function(ply)
lia.attribs.setup(ply)
end)