Compare commits

...

2 Commits

Author SHA1 Message Date
Kevin Mok a2700378c9
Command batching feature 2019-07-27 18:26:02 -04:00
Kevin Mok e4dfa68586
Switch to client-side mod to get parameters
Add todo.
2019-07-27 07:22:46 -04:00
2 changed files with 57 additions and 17 deletions

View File

@ -1,20 +1,47 @@
-- 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
end
aliases = {}
alias("gim", "giveme")
alias("grm", "grantme")
function alias(short, cmd_table)
aliases[short] = cmd_table
end
-- needs to be in minetest game?
-- alias("h", "home")
alias("sd", "shutdown")
alias("t", "teleport")
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 --
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 ""
-- run each cmd pair
if (not minetest.registered_chatcommands[cmd]) and (aliases[cmd]) then
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)
end
return true
end
end)

13
todo.md Normal file
View File

@ -0,0 +1,13 @@
- csm_restriction_flags instructions
- in-game alias modifications
- name teleport locations
- get current pos.
- new chat cmd
- toggle showing full command after running
- setting?
- store/read from JSON table?
- series of commands
- record?
- rename to aliases
- Server Command Aliases
- tests?