mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-28 02:03:46 +01:00
fully implement custom timer into logic
Nothing is done right now but the custoim timer is fully implemented into mTimer’s logic and is processed regularly. Next step is to write the custom timer formspec and logic.
This commit is contained in:
parent
5085711f6b
commit
60e55dc36a
@ -75,6 +75,7 @@ Current Date: @1=Aktuelles Datum: @1
|
||||
Ingame Time: @1=Spielzeit: @1
|
||||
Session Duration: @1=Sitzungsdauer: @1
|
||||
Session Start: @1=Sitzungsstart: @1
|
||||
Custom Timer: @1=Individueller Timer: @1
|
||||
|
||||
# Generic Formspec Strings
|
||||
Apply=Anwenden
|
||||
|
@ -26,7 +26,8 @@ mtimer.get_timer_data = function (player_name)
|
||||
ingame_time = time_data.ingame_time.formatted,
|
||||
session_start_time = time_data.session_start_time.formatted,
|
||||
session_duration = time_data.session_duration.formatted,
|
||||
host_time = time_data.host_time.formatted
|
||||
host_time = time_data.host_time.formatted,
|
||||
custom_timer = time_data.custom_timer.formatted
|
||||
}
|
||||
|
||||
values['formatted'] = values.format:gsub('{[0-9a-z]+}', {
|
||||
|
@ -243,6 +243,25 @@ local get_session_duration = function (player_name)
|
||||
end
|
||||
|
||||
|
||||
-- TODO: Implemet custom timer logic
|
||||
local get_custom_timer = function (player_name)
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
local player_meta = player:get_meta()
|
||||
local format = player_meta:get_string(m.meta.custom_timer_format.key)
|
||||
|
||||
local values = {}
|
||||
|
||||
values['formatted'] = format:gsub('{[a-z0-9]+}', {
|
||||
['{days}'] = 0,
|
||||
['{hours}'] = 0,
|
||||
['{minutes}'] = 0,
|
||||
['{seconds}'] = 0
|
||||
})
|
||||
|
||||
return values
|
||||
end
|
||||
|
||||
|
||||
-- Get the times
|
||||
--
|
||||
-- Returns the times for the given player referenced by the player’s name as
|
||||
@ -263,6 +282,7 @@ mtimer.get_times = function (player_name)
|
||||
real_time = get_real_time_universal(player_name, 'real'),
|
||||
host_time = get_real_time_universal(player_name, 'host'),
|
||||
session_start_time = get_real_time_universal(player_name, 'session'),
|
||||
session_duration = get_session_duration(player_name)
|
||||
session_duration = get_session_duration(player_name),
|
||||
custom_timer = get_custom_timer(player_name)
|
||||
}
|
||||
end
|
||||
|
@ -62,12 +62,13 @@ set('ingame_time_format', '{24h}:{min}')
|
||||
set('real_time_format', '{24h}:{min} ({isodate})')
|
||||
set('session_duration_format', '{hours}:{minutes}')
|
||||
set('session_start_time_format', '{isodate}T{isotime}')
|
||||
set('custom_timer_format', '{hours}:{minutes}:{seconds}')
|
||||
set('custom_timer_format', 'd: {days}, h: {hours}, m: {minutes}, s: {seconds}')
|
||||
|
||||
-- Timer display format (the HUD element’s content)
|
||||
set('timer_format', table.concat({
|
||||
S('Current Date: @1', '{rd}'),
|
||||
S('Ingame Time: @1', '{it}'),
|
||||
S('Session Start: @1', '{st}'),
|
||||
S('Session Duration: @1', '{sd}')
|
||||
S('Session Duration: @1', '{sd}'),
|
||||
S('Custom Timer: @1', '{ct}')
|
||||
}, '\n'), false)
|
||||
|
Loading…
Reference in New Issue
Block a user