diff --git a/init.lua b/init.lua index d026149..b93fe1c 100644 --- a/init.lua +++ b/init.lua @@ -1,19 +1,22 @@ aliases = {} -function alias(short, orig, param) - aliases[short] = { - orig = orig, - param = param or "" - } +function alias(short, cmd_table) + aliases[short] = cmd_table end - -alias("gim", "giveme") -alias("grm", "grantme") -- needs to be in minetest game? -- alias("h", "home") -alias("sd", "shutdown") -alias("t", "teleport") -alias("t0", "teleport", "0 0 0") + +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 @@ -27,13 +30,18 @@ minetest.register_on_sending_chat_message(function(message) end param = param or "" + -- run each cmd pair if (not minetest.registered_chatcommands[cmd]) and (aliases[cmd]) then - if aliases[cmd].param ~= "" then - param = aliases[cmd].param + 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 - -- 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) diff --git a/todo.md b/todo.md index f12e98a..0a337e0 100644 --- a/todo.md +++ b/todo.md @@ -1,5 +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?