diff options
Diffstat (limited to 'plugins/timer/init.lua')
-rw-r--r-- | plugins/timer/init.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/timer/init.lua b/plugins/timer/init.lua index e7d7155b4c1..1d67472b3c2 100644 --- a/plugins/timer/init.lua +++ b/plugins/timer/init.lua @@ -1,5 +1,6 @@ -- license:BSD-3-Clause -- copyright-holders:Vas Crabb +-- TODO: track time properly across soft reset and state load local exports = { name = 'timer', version = '0.0.3', @@ -9,6 +10,8 @@ local exports = { local timer = exports +local reset_subscription, stop_subscription + function timer.startplugin() local total_time = 0 local start_time = 0 @@ -38,7 +41,7 @@ function timer.startplugin() { '---', '', '' }, { _p("plugin-timer", "Current time"), sectohms(time), "off" }, { _p("plugin-timer", "Total time"), sectohms(total), "off" }, - { _p("plugin-timer", "Play Count"), play_count, "off" } }, + { _p("plugin-timer", "Play Count"), tostring(play_count), "off" } }, highlight, "idle" end @@ -53,8 +56,8 @@ function timer.startplugin() end - emu.register_start( - function() + reset_subscription = emu.add_machine_reset_notifier( + function () if emu.romname() ~= '___empty' then start_time = os.time() local persister = require('timer/timer_persist') @@ -62,8 +65,8 @@ function timer.startplugin() end end) - emu.register_stop( - function() + stop_subscription = emu.add_machine_stop_notifier( + function () if emu.romname() ~= '___empty' then local persister = require('timer/timer_persist') persister:update_totals(start_time) |