parent
eac314c1b7
commit
e4dfa68586
43
init.lua
43
init.lua
|
@ -1,15 +1,10 @@
|
|||
-- https://github.com/Uberi/Minetest-WorldEdit/blob/master/worldedit_shortcommands/init.lua
|
||||
function alias(short, orig)
|
||||
if not minetest.chatcommands[orig] then
|
||||
minetest.log("error", "custom_aliases: original command " .. orig .. " does not exist")
|
||||
return true
|
||||
end
|
||||
if minetest.chatcommands[short] then
|
||||
minetest.log("error", "custom_aliases: alias " .. short .. " already exists")
|
||||
return true
|
||||
end
|
||||
minetest.register_chatcommand(short, minetest.chatcommands[orig])
|
||||
return false
|
||||
aliases = {}
|
||||
|
||||
function alias(short, orig, param)
|
||||
aliases[short] = {
|
||||
orig = orig,
|
||||
param = param or ""
|
||||
}
|
||||
end
|
||||
|
||||
alias("gim", "giveme")
|
||||
|
@ -18,3 +13,27 @@ alias("grm", "grantme")
|
|||
-- alias("h", "home")
|
||||
alias("sd", "shutdown")
|
||||
alias("t", "teleport")
|
||||
alias("t0", "teleport", "0 0 0")
|
||||
|
||||
minetest.register_on_sending_chat_message(function(message)
|
||||
if message:sub(1,1) ~= "/" then
|
||||
return
|
||||
end
|
||||
|
||||
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
|
||||
if not cmd then
|
||||
minetest.display_chat_message("-!- Empty command")
|
||||
return true
|
||||
end
|
||||
param = param or ""
|
||||
|
||||
if (not minetest.registered_chatcommands[cmd]) and (aliases[cmd]) then
|
||||
if aliases[cmd].param ~= "" then
|
||||
param = aliases[cmd].param
|
||||
end
|
||||
-- minetest.display_chat_message("Param = " .. param)
|
||||
minetest.display_chat_message("alias for: /" .. aliases[cmd].orig .. " " .. param)
|
||||
minetest.run_server_chatcommand(aliases[cmd].orig, param)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue