util.monitor.has
Client
Checks whether a stat exists, either native or custom
Syntax
local result = util.monitor.has(
id
)Accepts both native and custom stat identifiers.
- Native stats — pass a
util.monitor.stat_nativeenum value to check whether a built-in Godot stat exists. - Custom stats — pass a
stringid to check whether a stat registered viautil.monitor.registerexists.
Parameters
| Type | Name | Description |
|---|---|---|
util.monitor.stat_native | string | id | Stat to look up: • When util.monitor.stat_native - checks a native stat by enum value• When string - checks a custom stat by its registered id |
Returns
| Type | Name | Description |
|---|---|---|
bool | result | true if the stat exists, false otherwise |
Examples
if util.monitor.has(util.monitor.stat_native.TIME_FPS) then
core.engine.print("info", "FPS stat is available")
endif util.monitor.has("my_resource:entity_count") then
core.engine.print("info", "Entity count:", util.monitor.get("my_resource:entity_count"))
endif not util.monitor.has("my_resource:cache_size") then
util.monitor.register("my_resource:cache_size", "Cache Size", function()
return cache.byte_size()
end, util.monitor.stat_format.MEMORY)
end