Display aliases in //help output nicer

This commit is contained in:
sfan5 2024-04-20 20:36:07 +02:00
parent 860d4a267d
commit 75d101116d
3 changed files with 17 additions and 6 deletions

View File

@ -114,6 +114,7 @@ end
function worldedit.register_command(name, def) function worldedit.register_command(name, def)
local def = table.copy(def) local def = table.copy(def)
assert(name and #name > 0) assert(name and #name > 0)
def.name = name
assert(def.privs) assert(def.privs)
def.require_pos = def.require_pos or 0 def.require_pos = def.require_pos or 0
assert(def.require_pos >= 0 and def.require_pos < 3) assert(def.require_pos >= 0 and def.require_pos < 3)
@ -130,6 +131,9 @@ function worldedit.register_command(name, def)
minetest.log("warning", "//" .. name .. " might be missing nodes_needed") minetest.log("warning", "//" .. name .. " might be missing nodes_needed")
end--]] end--]]
-- disable further modification
setmetatable(def, {__newindex = {}})
minetest.register_chatcommand("/" .. name, { minetest.register_chatcommand("/" .. name, {
privs = def.privs, privs = def.privs,
params = def.params, params = def.params,
@ -304,7 +308,7 @@ worldedit.register_command("about", {
end, end,
}) })
-- mostly copied from builtin/chatcommands.lua with minor modifications -- initially copied from builtin/chatcommands.lua
worldedit.register_command("help", { worldedit.register_command("help", {
privs = {}, privs = {},
params = "[all/<cmd>]", params = "[all/<cmd>]",
@ -315,11 +319,16 @@ worldedit.register_command("help", {
func = function(name, param) func = function(name, param)
local function format_help_line(cmd, def) local function format_help_line(cmd, def)
local msg = minetest.colorize("#00ffff", "//"..cmd) local msg = minetest.colorize("#00ffff", "//"..cmd)
if def.params and def.params ~= "" then if def.name ~= cmd then
msg = msg .. " " .. def.params msg = msg .. ": " .. S("alias to @1",
end minetest.colorize("#00ffff", "//"..def.name))
if def.description and def.description ~= "" then else
msg = msg .. ": " .. def.description if def.params and def.params ~= "" then
msg = msg .. " " .. def.params
end
if def.description and def.description ~= "" then
msg = msg .. ": " .. def.description
end
end end
return msg return msg
end end

View File

@ -26,6 +26,7 @@ Schematic was created with a newer version of WorldEdit.=
Get information about the WorldEdit mod= Get information about the WorldEdit mod=
WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3= WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3=
Get help for WorldEdit commands= Get help for WorldEdit commands=
alias to @1=
You are not allowed to use any WorldEdit commands.= You are not allowed to use any WorldEdit commands.=
Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.= Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=
Available commands:@n= Available commands:@n=

View File

@ -37,6 +37,7 @@ Schematic was created with a newer version of WorldEdit.=Schematic wurde mit ein
Get information about the WorldEdit mod=Informationen über den WorldEdit-Mod erhalten. Get information about the WorldEdit mod=Informationen über den WorldEdit-Mod erhalten.
WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3=WorldEdit @1 ist auf diesem Server verfügbar. Nutzen Sie @2, um eine Liste der Befehle zu erhalten, oder finden Sie weitere Informationen unter @3 WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3=WorldEdit @1 ist auf diesem Server verfügbar. Nutzen Sie @2, um eine Liste der Befehle zu erhalten, oder finden Sie weitere Informationen unter @3
Get help for WorldEdit commands=Hilfe für WorldEdit-Befehle erhalten Get help for WorldEdit commands=Hilfe für WorldEdit-Befehle erhalten
alias to @1=Alias für @1
You are not allowed to use any WorldEdit commands.=Ihnen ist nicht erlaubt WorldEdit-Befehle zu nutzen. You are not allowed to use any WorldEdit commands.=Ihnen ist nicht erlaubt WorldEdit-Befehle zu nutzen.
Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=Verfügbare Befehle: @1@n„@2“ benutzen, um mehr Informationen zu erhalten, oder „@3“, um alles aufzulisten. Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=Verfügbare Befehle: @1@n„@2“ benutzen, um mehr Informationen zu erhalten, oder „@3“, um alles aufzulisten.
Available commands:@n=Verfügbare Befehle:@n Available commands:@n=Verfügbare Befehle:@n