diff options
author | Diego Martinez <kaeza@users.sf.net> | 2014-05-22 13:08:25 -0300 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-05-24 17:33:59 -0400 |
commit | f0a9e7ddc854678d716afb90ae06e120480290a0 (patch) | |
tree | c92f4b280e051763b29c40c8c8938a9a69c0f293 /builtin | |
parent | 882e12f8ab5307a7814a0b6646ef7db9b448c236 (diff) | |
download | minetest-f0a9e7ddc854678d716afb90ae06e120480290a0.tar.gz minetest-f0a9e7ddc854678d716afb90ae06e120480290a0.tar.bz2 minetest-f0a9e7ddc854678d716afb90ae06e120480290a0.zip |
Sort commands and privs alphabetically in '/help'.
Also make a stray variable local.
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/chatcommands.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 6c5fea693..fb08d2a6b 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -56,24 +56,37 @@ core.register_chatcommand("help", { end if param == "" then local msg = "" - cmds = {} + local cmds = {} for cmd, def in pairs(core.chatcommands) do if core.check_player_privs(name, def.privs) then table.insert(cmds, cmd) end end + table.sort(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.") elseif param == "all" then - core.chat_send_player(name, "Available commands:") + local cmds = {} for cmd, def in pairs(core.chatcommands) do 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 + 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 - core.chat_send_player(name, "Available privileges:") + local privs = {} 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) end else |