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_native enum value; throws an error if the value is not a valid native stat.
  • Custom stats — pass a string id registered via util.monitor.register; returns false if the stat does not exist.

Parameters

TypeNameDescription
util.monitor.stat_native | stringidStat 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

TypeNameDescription
number | boolresultCurrent sampled value of the stat, false otherwise

Examples

Read the current FPS
core.engine.print("info", "FPS:", util.monitor.get(util.monitor.stat_native.TIME_FPS))
Read static memory usage
core.engine.print("info", "Memory (bytes):", util.monitor.get(util.monitor.stat_native.MEMORY_STATIC))
Read a custom stat
core.engine.print("info", "Entity count:", util.monitor.get("my_resource:entity_count"))
Safely read a custom stat with an existence check
if util.monitor.has("my_resource:cache_size") then
    core.engine.print("info", "Cache size (bytes):", util.monitor.get("my_resource:cache_size"))
end

On this page