mtimer/system/get_timer_data.lua
2019-02-22 14:08:44 +01:00

29 lines
1013 B
Lua

local m = mtimer
local S = m.translator
mtimer.get_timer_data = function (player_name)
local player_meta = minetest.get_player_by_name(player_name):get_meta()
local time_data = mtimer.get_times(player_name)
local ingame_time = time_data.ingame_time.formatted
local session_start_time = time_data.session_start_time.formatted
local session_duration = time_data.session_duration.formatted
local values = {
format = player_meta:get_string(m.meta.timer_format.key),
real_world_date = time_data.real_time.formatted,
ingame_time = time_data.ingame_time.formatted,
session_start_time = time_data.session_start_time.formatted,
session_duration = time_data.session_duration.formatted
}
values['formatted'] = values.format:gsub('{[0-9a-z]+}', {
['{rd}'] = values.real_world_date,
['{it}'] = values.ingame_time,
['{st}'] = values.session_start_time,
['{sd}'] = values.session_duration,
})
return values
end