2019-07-27 13:18:10 +02:00
|
|
|
aliases = {}
|
|
|
|
|
2019-07-28 00:26:02 +02:00
|
|
|
function alias(short, cmd_table)
|
|
|
|
aliases[short] = cmd_table
|
2019-07-27 04:18:46 +02:00
|
|
|
end
|
|
|
|
-- needs to be in minetest game?
|
|
|
|
-- alias("h", "home")
|
2019-07-28 00:26:02 +02:00
|
|
|
|
|
|
|
aliases["clc"] = { { "fp", "s1 -2 1 2" }, { "fp", "s2 2 1 -2" }, { "cl" } }
|
|
|
|
aliases["day"] = { { "time", "6000" } }
|
|
|
|
aliases["gim"] = { { "giveme" } }
|
|
|
|
aliases["grm"] = { { "grantme" } }
|
|
|
|
aliases["grma"] = { { "grantme", "all" } }
|
|
|
|
aliases["sd"] = { { "shutdown" } }
|
|
|
|
aliases["t"] = { { "teleport" } }
|
|
|
|
aliases["tr"] = { { "pulverize" } }
|
|
|
|
aliases["t0"] = { { "teleport", "0 0 0" }, { "teleport", "1 1 1" } }
|
|
|
|
|
|
|
|
-- TODO: move WorldEdit aliases here --
|
2019-07-27 13:18:10 +02:00
|
|
|
|
|
|
|
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 ""
|
|
|
|
|
2019-07-28 00:26:02 +02:00
|
|
|
-- run each cmd pair
|
2019-07-27 13:18:10 +02:00
|
|
|
if (not minetest.registered_chatcommands[cmd]) and (aliases[cmd]) then
|
2019-07-28 00:26:02 +02:00
|
|
|
for i, cmd_pair in ipairs(aliases[cmd]) do
|
|
|
|
-- only keep passed in param if first cmd and no given param
|
|
|
|
if table.getn(cmd_pair) > 1 then
|
|
|
|
param = cmd_pair[2]
|
|
|
|
elseif i > 1 then
|
|
|
|
param = ""
|
|
|
|
end
|
|
|
|
minetest.display_chat_message("alias for: /" .. cmd_pair[1] .. " " .. param)
|
|
|
|
minetest.run_server_chatcommand(cmd_pair[1], param)
|
2019-07-27 13:18:10 +02:00
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end)
|