Switch to client-side mod to get parameters

Add todo.
This commit is contained in:
Kevin Mok 2019-07-27 07:18:10 -04:00
parent eac314c1b7
commit e4dfa68586
Signed by: Kevin-Mok
GPG Key ID: AEA75288DC135CF5
2 changed files with 36 additions and 12 deletions

View File

@ -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)

5
todo.md Normal file
View File

@ -0,0 +1,5 @@
- csm_restriction_flags instructions
- in-game alias modifications
- name teleport locations
- toggle showing full command after running
- setting?