2019-02-22 14:08:44 +01:00
|
|
|
local m = mtimer
|
|
|
|
local S = m.translator
|
|
|
|
|
2019-02-22 20:33:42 +01:00
|
|
|
-- Get parsed timer data
|
|
|
|
--
|
|
|
|
-- Returns the parsed timer data (i.e. all variables are replaced with their
|
|
|
|
-- respective values) for the given player referenced by the name.
|
|
|
|
--
|
|
|
|
-- The returned table holds the formatted version as well as the individual
|
|
|
|
-- times (session start, current date, etc.) as configured via the respective
|
|
|
|
-- dialogs. This will be used for the Timer itself as well as in the
|
|
|
|
-- configuration formspec.
|
|
|
|
--
|
|
|
|
-- @param player_name The name of the player to get the timer data for
|
|
|
|
-- @return table The timer data of the player
|
2019-02-22 14:08:44 +01:00
|
|
|
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,
|
2019-04-12 21:56:06 +02:00
|
|
|
session_duration = time_data.session_duration.formatted,
|
|
|
|
host_time = time_data.host_time.formatted
|
2019-02-22 14:08:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2021-02-10 21:21:24 +01:00
|
|
|
['{ht}'] = values.host_time,
|
|
|
|
['{ct}'] = values.custom_timer
|
2019-02-22 14:08:44 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
return values
|
|
|
|
end
|