Compare commits
2 Commits
server-wip
...
master
Author | SHA1 | Date |
---|---|---|
Kevin Mok | a2700378c9 | |
Kevin Mok | e4dfa68586 |
61
init.lua
61
init.lua
|
@ -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)
|
||||
|
|
|
@ -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?
|
Loading…
Reference in New Issue