2019-02-16 16:45:32 +01:00
|
|
|
local m = mtimer
|
|
|
|
local S = m.translator
|
2019-02-16 17:33:16 +01:00
|
|
|
local fs = m.show_formspec
|
|
|
|
local cs = minetest.chat_send_player
|
|
|
|
|
|
|
|
|
|
|
|
local command = function (command)
|
|
|
|
return minetest.colorize('cyan', '/mtimer '..command..' ')
|
|
|
|
end
|
2019-02-16 16:45:32 +01:00
|
|
|
|
|
|
|
minetest.register_chatcommand('mtimer', {
|
|
|
|
description = S('Configure timer display'),
|
2019-02-21 21:07:35 +01:00
|
|
|
params = '<vi/po/co/tz/in/re/st/sd/te/help>',
|
2019-02-16 16:45:32 +01:00
|
|
|
func = function(name, parameters)
|
|
|
|
local action = parameters:match('%a+')
|
2019-02-16 17:33:16 +01:00
|
|
|
|
|
|
|
if not minetest.get_player_by_name(name) then return end
|
|
|
|
if not action then fs.main_menu(name) end
|
|
|
|
|
|
|
|
if action == 'vi' then fs.set_visibility(name) end
|
|
|
|
if action == 'po' then fs.set_position(name) end
|
|
|
|
if action == 'co' then fs.set_color(name) end
|
|
|
|
if action == 'tz' then fs.timezone_offset(name) end
|
2019-02-21 16:16:10 +01:00
|
|
|
if action == 'in' then fs.ingame_time_format(name) end
|
2019-02-21 21:07:35 +01:00
|
|
|
if action == 're' then fs.real_world_time_format(name) end
|
|
|
|
if action == 'st' then fs.session_start_time_format(name) end
|
|
|
|
if action == 'sd' then fs.session_duration_format(name) end
|
2019-02-16 17:33:16 +01:00
|
|
|
if action == 'te' then fs.timer_text(name) end
|
|
|
|
|
|
|
|
if action == 'help' then
|
|
|
|
local message = {
|
|
|
|
command('vi')..S('Set Visibility'),
|
|
|
|
command('po')..S('Set Position'),
|
|
|
|
command('co')..S('Set Color'),
|
|
|
|
command('tz')..S('Timezone Offset'),
|
2019-02-21 16:16:10 +01:00
|
|
|
command('in')..S('Ingame Time Format'),
|
|
|
|
command('re')..S('Real-World Time Format'),
|
2019-02-21 21:07:35 +01:00
|
|
|
command('st')..S('Session Start Time Format'),
|
|
|
|
command('sd')..S('Session Duration Format'),
|
2019-02-16 17:33:16 +01:00
|
|
|
command('te')..S('Set Timer Text'),
|
|
|
|
command(' ')..S('Open Main Menu')
|
|
|
|
}
|
|
|
|
cs(name, table.concat(message, '\n'))
|
|
|
|
end
|
2019-02-16 16:45:32 +01:00
|
|
|
end
|
|
|
|
})
|