mod-hidename/command.lua

97 lines
2.0 KiB
Lua
Raw Normal View History

--[[ MIT LICENSE HEADER
Copyright © 2017 Jordan Irwin (AntumDeluge)
See: LICENSE.txt
--]]
2017-07-28 02:20:04 -07:00
--- *hidename* chat commands
--
-- @script command.lua
2017-07-28 02:20:04 -07:00
2017-07-27 18:09:24 -07:00
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.global_exists('intllib') then
if intllib.make_gettext_pair then
S = intllib.make_gettext_pair()
else
S = intllib.Getter()
end
else
S = function(s) return s end
end
local params = {
'hide',
'show',
'status',
}
local params_string = '[' .. table.concat(params, '|') .. ']'
2017-07-28 02:20:04 -07:00
--- *nametag* chat command.
--
-- Displays nametag info or sets visibility.
--
-- @chatcmd nametag
-- @chatparam mode
-- @option ***hide*** : Sets player nametag hidden
-- @option ***show*** : Sets player nametag visible
-- @option ***status*** : Displays nametag text & visible state (default)
-- @usage
-- /nametag [option]
-- /nametag hide
core.register_chatcommand('nametag', {
params = params_string,
description = S('Get nametag info or set visibility'),
func = function(name, param)
-- Split parameters into case-insensitive list
param = string.split(string.lower(param), ' ')
local mode = param[1]
-- Default to "status"
if mode == nil or mode == 'status' then
hidename.tellStatus(name)
return true
elseif mode == 'hide' then
return hidename.hide(name)
elseif mode == 'show' then
return hidename.show(name)
end
core.chat_send_player(name, S('Error: Unknown parameter:') .. ' ' .. mode)
return false
end
})
2017-07-28 02:20:04 -07:00
--- *hidename* chat command.
--
-- Sets player's nametag hidden from others.
--
-- @chatcmd hidename
-- @usage /hidename
core.register_chatcommand('hidename', {
description = S('Make nametag hidden'),
func = function(name, param)
2017-07-27 19:29:05 -07:00
return hidename.hide(name)
end,
})
2017-07-28 02:20:04 -07:00
--- *showname* chat command.
--
-- Sets player's nametag visible to others.
-- @chatcmd showname
-- @usage /showname
core.register_chatcommand('showname', {
description = S('Make nametag visible'),
func = function(name, param)
2017-07-27 19:29:05 -07:00
return hidename.show(name)
end,
})