Skip to content

Commit dc8c61b

Browse files
sfan5MoNTE48
authored andcommitted
Display aliases in //help output nicer
1 parent 8fcc547 commit dc8c61b

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

worldedit_commands/init.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ end
114114
function worldedit.register_command(name, def)
115115
local def = table.copy(def)
116116
assert(name and #name > 0)
117+
def.name = name
117118
assert(def.privs)
118119
def.require_pos = def.require_pos or 0
119120
assert(def.require_pos >= 0 and def.require_pos < 3)
@@ -130,6 +131,9 @@ function worldedit.register_command(name, def)
130131
minetest.log("warning", "//" .. name .. " might be missing nodes_needed")
131132
end--]]
132133

134+
-- disable further modification
135+
setmetatable(def, {__newindex = {}})
136+
133137
minetest.register_chatcommand("/" .. name, {
134138
privs = def.privs,
135139
params = def.params,
@@ -315,7 +319,7 @@ worldedit.register_command("about", {
315319
end,
316320
})
317321

318-
-- mostly copied from builtin/chatcommands.lua with minor modifications
322+
-- initially copied from builtin/chatcommands.lua
319323
worldedit.register_command("help", {
320324
privs = {worldedit=true},
321325
params = "[all/<cmd>]",
@@ -326,11 +330,16 @@ worldedit.register_command("help", {
326330
func = function(name, param)
327331
local function format_help_line(cmd, def)
328332
local msg = minetest.colorize("#00ffff", "//"..cmd)
329-
if def.params and def.params ~= "" then
330-
msg = msg .. " " .. def.params
331-
end
332-
if def.description and def.description ~= "" then
333-
msg = msg .. ": " .. def.description
333+
if def.name ~= cmd then
334+
msg = msg .. ": " .. S("alias to @1",
335+
minetest.colorize("#00ffff", "//"..def.name))
336+
else
337+
if def.params and def.params ~= "" then
338+
msg = msg .. " " .. def.params
339+
end
340+
if def.description and def.description ~= "" then
341+
msg = msg .. ": " .. def.description
342+
end
334343
end
335344
return msg
336345
end

worldedit_commands/locale/template.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Schematic was created with a newer version of WorldEdit.=
2626
Get information about the WorldEdit mod=
2727
WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3=
2828
Get help for WorldEdit commands=
29+
alias to @1=
2930
You are not allowed to use any WorldEdit commands.=
3031
Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=
3132
Available commands:@n=

worldedit_commands/locale/worldedit_commands.de.tr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Schematic was created with a newer version of WorldEdit.=Schematic wurde mit ein
3737
Get information about the WorldEdit mod=Informationen über den WorldEdit-Mod erhalten.
3838
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
3939
Get help for WorldEdit commands=Hilfe für WorldEdit-Befehle erhalten
40+
alias to @1=Alias für @1
4041
You are not allowed to use any WorldEdit commands.=Ihnen ist nicht erlaubt WorldEdit-Befehle zu nutzen.
4142
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.
4243
Available commands:@n=Verfügbare Befehle:@n

0 commit comments

Comments
 (0)