mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-24 16:23:44 +01:00
43 lines
1.5 KiB
Lua
43 lines
1.5 KiB
Lua
local m = mtimer
|
|
local S = m.translator
|
|
local fs = m.show_formspec
|
|
local cs = minetest.chat_send_player
|
|
|
|
|
|
local command = function (command)
|
|
return minetest.colorize('cyan', '/mtimer '..command..' ')
|
|
end
|
|
|
|
minetest.register_chatcommand('mtimer', {
|
|
description = S('Configure timer display'),
|
|
params = '<vi/po/co/tz/in/re/te/help>',
|
|
func = function(name, parameters)
|
|
local action = parameters:match('%a+')
|
|
|
|
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
|
|
if action == 'in' then fs.ingame_time(name) end
|
|
if action == 're' then fs.real_time(name) end
|
|
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'),
|
|
command('in')..S('Ingame Time Representation'),
|
|
command('re')..S('Real World Time Representation'),
|
|
command('te')..S('Set Timer Text'),
|
|
command(' ')..S('Open Main Menu')
|
|
}
|
|
cs(name, table.concat(message, '\n'))
|
|
end
|
|
end
|
|
})
|