mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-12-01 03:33:56 +01:00
53 lines
2.3 KiB
Lua
53 lines
2.3 KiB
Lua
local m = mtimer
|
|
local S = m.translator
|
|
local esc = minetest.formspec_escape
|
|
local line = mtimer.get_table_line
|
|
|
|
|
|
-- Real Time Universal Formspec
|
|
--
|
|
-- This formspec can be used to show formatting options for all real-world time
|
|
-- values that can be formatted within mTimer. Since all the real-world times
|
|
-- are defined identically this formspec exists so it has to be defined only
|
|
-- once and can be re-used as needed.
|
|
--
|
|
-- @param player_name The name of the player to show the formspec to
|
|
-- @config time_type A time type that is provided by the `get_times` function
|
|
-- @return void
|
|
-- @see mtimer.get_times
|
|
mtimer.dialog.real_time_universal = function (player_name, config)
|
|
local time_data = mtimer.get_times(player_name)[config.time_type]
|
|
local vars = time_data.variables
|
|
|
|
mtimer.show_formspec(config.formspec_name, {
|
|
title = config.title,
|
|
show_to = player_name,
|
|
height = 8.75,
|
|
formspec = {
|
|
'field_close_on_enter[format;false]',
|
|
'field[0,0;+contentWidth,0.5;format;;'..esc(time_data.format)..']',
|
|
'container[0,1.5]',
|
|
line(0, '', S('Variable'), S('Current Value')),
|
|
line(1, '-'),
|
|
line(2, S('Hours (24h)'), '{24h}', vars.hours_24),
|
|
line(3, S('Hours (12h)'), '{12h}', vars.hours_12),
|
|
line(4, S('Minutes'), '{min}', vars.minutes),
|
|
line(5, S('Seconds'), '{sec}', vars.seconds),
|
|
line(6, '-'),
|
|
line(7, S('Day Name'), '{dname}', vars.dayname),
|
|
line(8, S('Month Name'), '{mname}', vars.monthname),
|
|
line(9, '-'),
|
|
line(10, S('Year'), '{year}', vars.year),
|
|
line(11, S('Month'), '{month}', vars.month),
|
|
line(12, S('Day'), '{day}', vars.day),
|
|
line(13, '-'),
|
|
line(14, S('ISO 8601 Date'), '{isodate}', vars.iso8601_date),
|
|
line(15, S('ISO 8601 Time'), '{isotime}', vars.iso8601_time),
|
|
line(16, S('Timestamp'), '{timestamp}', vars.timestamp),
|
|
line(17, '-'),
|
|
line(18, S('Current Result'), esc(time_data.formatted), ''),
|
|
'container_end[]'
|
|
}
|
|
})
|
|
end
|