util.monitor.get
Client
Retrieves the current value of a stat, either native or custom
Syntax
local result = util.monitor.get(
id
)The stat must exist before reading it.
- Native stats — pass a
util.monitor.stat_nativeenum value; throws an error if the value is not a valid native stat. - Custom stats — pass a
stringid registered viautil.monitor.register; returnsfalseif the stat does not exist.
Parameters
| Type | Name | Description |
|---|---|---|
util.monitor.stat_native | string | id | Stat to read: • When util.monitor.stat_native - reads a native stat by enum value• When string - reads a custom stat by its registered id |
Returns
| Type | Name | Description |
|---|---|---|
number | bool | result | Current sampled value of the stat, false otherwise |
Examples
core.engine.print("info", "FPS:", util.monitor.get(util.monitor.stat_native.TIME_FPS))core.engine.print("info", "Memory (bytes):", util.monitor.get(util.monitor.stat_native.MEMORY_STATIC))core.engine.print("info", "Entity count:", util.monitor.get("my_resource:entity_count"))if util.monitor.has("my_resource:cache_size") then
core.engine.print("info", "Cache size (bytes):", util.monitor.get("my_resource:cache_size"))
end