mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
plugins/timer: save to the correct file (nw)
This commit is contained in:
parent
db784e019f
commit
0e5c6cb8c1
@ -26,9 +26,7 @@ function timer.startplugin()
|
|||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
emu.register_start(function()
|
local function save()
|
||||||
local file
|
|
||||||
if timer_started then
|
|
||||||
total_time = total_time + (os.time() - start_time)
|
total_time = total_time + (os.time() - start_time)
|
||||||
os.remove(get_filename()) -- truncate file
|
os.remove(get_filename()) -- truncate file
|
||||||
file = io.open(get_filename(), "w")
|
file = io.open(get_filename(), "w")
|
||||||
@ -41,6 +39,13 @@ function timer.startplugin()
|
|||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
emu.register_start(function()
|
||||||
|
local file
|
||||||
|
if timer_started then
|
||||||
|
save()
|
||||||
|
end
|
||||||
timer_started = true
|
timer_started = true
|
||||||
local file = io.open(get_filename(), "r")
|
local file = io.open(get_filename(), "r")
|
||||||
if file then
|
if file then
|
||||||
@ -50,11 +55,17 @@ function timer.startplugin()
|
|||||||
start_time = os.time()
|
start_time = os.time()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
emu.register_stop(function()
|
||||||
|
timer_started = false
|
||||||
|
save()
|
||||||
|
total_time = 0
|
||||||
|
end)
|
||||||
|
|
||||||
local function sectohms(time)
|
local function sectohms(time)
|
||||||
local hrs = math.floor(time / 3600)
|
local hrs = math.floor(time / 3600)
|
||||||
local min = math.floor((time % 3600) / 60)
|
local min = math.floor((time % 3600) / 60)
|
||||||
local sec = math.floor(time % 60)
|
local sec = math.floor(time % 60)
|
||||||
return string.format("%02d:%02d:%02d", hrs, min, sec)
|
return string.format("%03d:%02d:%02d", hrs, min, sec)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function menu_populate()
|
local function menu_populate()
|
||||||
|
Loading…
Reference in New Issue
Block a user