diff options
author | 2016-04-08 13:18:04 -0500 | |
---|---|---|
committer | 2016-04-08 13:18:04 -0500 | |
commit | aee051e46dc45190affe13457844bc97fb389c82 (patch) | |
tree | 0b9d05156a246493ab8b4a05dcb04b2b19f52713 /plugins/timer | |
parent | 4f1ffa851ea372a18a67bb937ce8f0bc1e72c7ad (diff) |
plugins/timer: add play count (nw)
Diffstat (limited to 'plugins/timer')
-rw-r--r-- | plugins/timer/init.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/timer/init.lua b/plugins/timer/init.lua index 68fdee1ea4d..3b00bb01f9b 100644 --- a/plugins/timer/init.lua +++ b/plugins/timer/init.lua @@ -15,6 +15,7 @@ function timer.startplugin() local timer_started = false local total_time = 0 local start_time = 0 + local play_count = 0 local function get_filename() local path @@ -35,7 +36,8 @@ function timer.startplugin() file = io.open(get_filename(), "w") end if file then - file:write(total_time) + file:write(total_time .. "\n") + file:write(play_count) file:close() end end @@ -50,21 +52,24 @@ function timer.startplugin() local file = io.open(get_filename(), "r") if file then total_time = file:read("n") + play_count = file:read("n") file:close() end start_time = os.time() + play_count = play_count + 1 end) emu.register_stop(function() timer_started = false save() total_time = 0 + play_count = 0 end) local function sectohms(time) local hrs = math.floor(time / 3600) local min = math.floor((time % 3600) / 60) - local sec = math.floor(time % 60) + local sec = time % 60 return string.format("%03d:%02d:%02d", hrs, min, sec) end @@ -73,7 +78,9 @@ function timer.startplugin() return {{ "Current time", "", 32 }, { sectohms(time), "", 32 }, { "Total time", "", 32 }, - { sectohms(total_time + time), "", 32 }} + { sectohms(total_time + time), "", 32 }, + { "Play Count", "", 32 }, + { play_count, "", 32 }} end local function menu_callback(index, event) |