Command batching feature
This commit is contained in:
parent
e4dfa68586
commit
a2700378c9
40
init.lua
40
init.lua
|
@ -1,19 +1,22 @@
|
||||||
aliases = {}
|
aliases = {}
|
||||||
|
|
||||||
function alias(short, orig, param)
|
function alias(short, cmd_table)
|
||||||
aliases[short] = {
|
aliases[short] = cmd_table
|
||||||
orig = orig,
|
|
||||||
param = param or ""
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
alias("gim", "giveme")
|
|
||||||
alias("grm", "grantme")
|
|
||||||
-- needs to be in minetest game?
|
-- needs to be in minetest game?
|
||||||
-- alias("h", "home")
|
-- alias("h", "home")
|
||||||
alias("sd", "shutdown")
|
|
||||||
alias("t", "teleport")
|
aliases["clc"] = { { "fp", "s1 -2 1 2" }, { "fp", "s2 2 1 -2" }, { "cl" } }
|
||||||
alias("t0", "teleport", "0 0 0")
|
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 --
|
||||||
|
|
||||||
minetest.register_on_sending_chat_message(function(message)
|
minetest.register_on_sending_chat_message(function(message)
|
||||||
if message:sub(1,1) ~= "/" then
|
if message:sub(1,1) ~= "/" then
|
||||||
|
@ -27,13 +30,18 @@ minetest.register_on_sending_chat_message(function(message)
|
||||||
end
|
end
|
||||||
param = param or ""
|
param = param or ""
|
||||||
|
|
||||||
|
-- run each cmd pair
|
||||||
if (not minetest.registered_chatcommands[cmd]) and (aliases[cmd]) then
|
if (not minetest.registered_chatcommands[cmd]) and (aliases[cmd]) then
|
||||||
if aliases[cmd].param ~= "" then
|
for i, cmd_pair in ipairs(aliases[cmd]) do
|
||||||
param = aliases[cmd].param
|
-- 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)
|
||||||
end
|
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
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
8
todo.md
8
todo.md
|
@ -1,5 +1,13 @@
|
||||||
- csm_restriction_flags instructions
|
- csm_restriction_flags instructions
|
||||||
- in-game alias modifications
|
- in-game alias modifications
|
||||||
- name teleport locations
|
- name teleport locations
|
||||||
|
- get current pos.
|
||||||
|
- new chat cmd
|
||||||
- toggle showing full command after running
|
- toggle showing full command after running
|
||||||
- setting?
|
- setting?
|
||||||
|
- store/read from JSON table?
|
||||||
|
- series of commands
|
||||||
|
- record?
|
||||||
|
- rename to aliases
|
||||||
|
- Server Command Aliases
|
||||||
|
- tests?
|
||||||
|
|
Loading…
Reference in New Issue