Skip to content

Commit

Permalink
Display aliases in //help output nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Apr 20, 2024
1 parent ac4f0ca commit 3edb506
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
21 changes: 15 additions & 6 deletions worldedit_commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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>]",
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions worldedit_commands/locale/template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions worldedit_commands/locale/worldedit_commands.de.tr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3edb506

Please sign in to comment.