1 local minecraftaliases
= true
4 if minetest
.get_modpath("intllib") then
7 S
= function(s
,a
,...)a
={a
,...}return s
:gsub("@(%d+)",function(n
)return a
[tonumber(n
)]end)end
10 local function handle_kill_command(suspect
, victim
)
11 if minetest
.settings
:get_bool("enable_damage") == false then
12 return false, S("Players can't be killed right now, damage has been disabled.")
14 local victimref
= minetest
.get_player_by_name(victim
)
15 if victimref
== nil then
16 return false, S("Player @1 does not exist.", victim
)
17 elseif victimref
:get_hp() <= 0 then
18 if suspect
== victim
then
19 return false, S("You are already dead")
21 return false, S("@1 is already dead", victim
)
24 if not suspect
== victim
then
25 minetest
.log("action", S("@1 killed @2", suspect
, victim
))
27 -- If player holds a totem of undying, destroy it before killing,
28 -- so it doesn't rescue the player.
29 local wield
= victimref
:get_wielded_item()
30 if wield
:get_name() == "mobs_mc:totem" then
31 victimref
:set_wielded_item("")
38 if minetest
.registered_chatcommands
["kill"] then
39 minetest
.unregister_chatcommand("kill")
41 minetest
.register_chatcommand("kill", {
42 params
= S("[<name>]"),
43 description
= S("Kill player or yourself"),
44 privs
= {server
=true},
45 func
= function(name
, param
)
48 return handle_kill_command(name
, name
)
50 return handle_kill_command(name
, param
)
55 minetest
.register_privilege("announce", {
56 description
= S("Can use /say"),
57 give_to_singleplayer
= false,
59 minetest
.register_chatcommand("say", {
60 params
= S("<message>"),
61 description
= S("Send a message to every player"),
62 privs
= {announce
=true},
63 func
= function(name
, param
)
65 return false, S("Invalid usage, see /help say.")
67 minetest
.chat_send_all(("["..name
.."] "..param
))
72 minetest
.register_chatcommand("setblock", {
73 params
= S("<X>,<Y>,<Z> <NodeString>"),
74 description
= S("Set node at given position"),
75 privs
= {give
=true, interact
=true},
76 func
= function(name
, param
)
78 local nodestring
= nil
79 p
.x
, p
.y
, p
.z
, nodestring
= param
:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) +(.+)$")
80 p
.x
, p
.y
, p
.z
= tonumber(p
.x
), tonumber(p
.y
), tonumber(p
.z
)
81 if p
.x
and p
.y
and p
.z
and nodestring
then
82 local itemstack
= ItemStack(nodestring
)
83 if itemstack
:is_empty() or not minetest
.registered_nodes
[itemstack
:get_name()] then
84 return false, S("Invalid node")
86 minetest
.set_node(p
, {name
=nodestring
})
87 return true, S("@1 spawned.", nodestring
)
89 return false, S("Invalid parameters (see /help setblock)")
93 minetest
.register_chatcommand("list", {
94 description
= "Show who is logged on",
99 for _
, player
in ipairs(minetest
.get_connected_players()) do
100 players
= players
..player
:get_player_name().."\n"
102 minetest
.chat_send_player(name
, players
)
106 minetest
.register_chatcommand("seed", {
107 description
= "Displays the world seed",
110 func
= function(name
)
111 minetest
.chat_send_player(name
, minetest
.get_mapgen_setting("seed"))
115 local function register_chatcommand_alias(alias
, cmd
)
116 local def
= minetest
.chatcommands
[cmd
]
117 minetest
.register_chatcommand(alias
, def
)
120 if minecraftaliases
then
121 register_chatcommand_alias("?", "help")
122 register_chatcommand_alias("who", "list")
123 register_chatcommand_alias("pardon", "unban")
124 register_chatcommand_alias("stop", "shutdown")
125 register_chatcommand_alias("summon", "spawnentity")
126 register_chatcommand_alias("tell", "msg")
127 register_chatcommand_alias("w", "msg")
128 register_chatcommand_alias("tp", "teleport")
129 register_chatcommand_alias("clear", "clearinv")
131 minetest
.register_chatcommand("banlist", {
132 description
= S("List bans"),
133 privs
= minetest
.chatcommands
["ban"].privs
,
134 func
= function(name
)
135 return true, S("Ban list: @1", core
.get_ban_list())