Skip to main content

Timer

Namespace: hexis.timer

Track elapsed time for sessions and statistics.


Methods

hexis.timer.start()

Start the timer.

hexis.timer.start()

hexis.timer.stop()

Stop the timer.

hexis.timer.stop()

hexis.timer.reset()

Reset the timer to zero.

hexis.timer.reset()

hexis.timer.elapsed()

Get elapsed time in seconds.

local seconds = hexis.timer.elapsed()
hexis.log.info("Elapsed: " .. seconds .. " seconds")

hexis.timer.elapsed_ms()

Get elapsed time in milliseconds.

local ms = hexis.timer.elapsed_ms()

hexis.timer.formatted()

Get formatted time string.

local time = hexis.timer.formatted()  -- "1h 23m 45s"
hexis.hud.set_var("elapsed_time", time)

hexis.timer.is_running()

Check if timer is currently running.

if hexis.timer.is_running() then
hexis.log.info("Timer active")
end

Example Usage

hexis.timer.start()

while hexis.running() do
-- Update HUD with elapsed time
hexis.hud.set_var("time", hexis.timer.formatted())
hexis.sleep(1000)
end

hexis.timer.stop()
hexis.log.info("Total time: " .. hexis.timer.formatted())