forked from Mirrorlandia_minetest/minetest
Sort commands and privs alphabetically in '/help'.
Also make a stray variable local.
This commit is contained in:
parent
882e12f8ab
commit
f0a9e7ddc8
@ -56,24 +56,37 @@ core.register_chatcommand("help", {
|
|||||||
end
|
end
|
||||||
if param == "" then
|
if param == "" then
|
||||||
local msg = ""
|
local msg = ""
|
||||||
cmds = {}
|
local cmds = {}
|
||||||
for cmd, def in pairs(core.chatcommands) do
|
for cmd, def in pairs(core.chatcommands) do
|
||||||
if core.check_player_privs(name, def.privs) then
|
if core.check_player_privs(name, def.privs) then
|
||||||
table.insert(cmds, cmd)
|
table.insert(cmds, cmd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.sort(cmds)
|
||||||
core.chat_send_player(name, "Available commands: "..table.concat(cmds, " "))
|
core.chat_send_player(name, "Available commands: "..table.concat(cmds, " "))
|
||||||
core.chat_send_player(name, "Use '/help <cmd>' to get more information, or '/help all' to list everything.")
|
core.chat_send_player(name, "Use '/help <cmd>' to get more information, or '/help all' to list everything.")
|
||||||
elseif param == "all" then
|
elseif param == "all" then
|
||||||
core.chat_send_player(name, "Available commands:")
|
local cmds = {}
|
||||||
for cmd, def in pairs(core.chatcommands) do
|
for cmd, def in pairs(core.chatcommands) do
|
||||||
if core.check_player_privs(name, def.privs) then
|
if core.check_player_privs(name, def.privs) then
|
||||||
core.chat_send_player(name, format_help_line(cmd, def))
|
table.insert(cmds, cmd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.sort(cmds)
|
||||||
|
core.chat_send_player(name, "Available commands:")
|
||||||
|
for _, cmd in ipairs(cmds) do
|
||||||
|
local def = core.chatcommands[cmd]
|
||||||
|
core.chat_send_player(name, format_help_line(cmd, def))
|
||||||
|
end
|
||||||
elseif param == "privs" then
|
elseif param == "privs" then
|
||||||
core.chat_send_player(name, "Available privileges:")
|
local privs = {}
|
||||||
for priv, def in pairs(core.registered_privileges) do
|
for priv, def in pairs(core.registered_privileges) do
|
||||||
|
table.insert(privs, priv)
|
||||||
|
end
|
||||||
|
table.sort(privs)
|
||||||
|
core.chat_send_player(name, "Available privileges:")
|
||||||
|
for _, priv in ipairs(privs) do
|
||||||
|
local def = core.registered_privileges[priv]
|
||||||
core.chat_send_player(name, priv..": "..def.description)
|
core.chat_send_player(name, priv..": "..def.description)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user