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

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

@ -26,6 +26,7 @@ Schematic was created with a newer version of WorldEdit.=
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=
Get help for WorldEdit commands=
alias to @1=
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:@n=

@ -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.
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
alias to @1=Alias für @1
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:@n=Verfügbare Befehle:@n