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("damage_enabled") == 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 minetest
.register_privilege("kill", {
39 description
= S("Can use /kill"),
40 give_to_singleplayer
= false,
42 minetest
.register_privilege("announce", {
43 description
= S("Can use /say"),
44 give_to_singleplayer
= false,
47 minetest
.register_chatcommand("kill", {
48 params
= S("[<name>]"),
49 description
= S("Kill player"),
51 func
= function(name
, param
)
54 return handle_kill_command(name
, name
)
56 return handle_kill_command(name
, param
)
61 minetest
.register_chatcommand("say", {
62 params
= S("<message>"),
63 description
= S("Send a message to every player"),
64 privs
= {announce
=true},
65 func
= function(name
, param
)
67 return false, S("Invalid usage, see /help say.")
69 minetest
.chat_send_all(("["..name
.."] "..param
))
74 minetest
.register_chatcommand("setblock", {
75 params
= S("<X>,<Y>,<Z> <NodeString>"),
76 description
= S("Set node at given position"),
77 privs
= {give
=true, interact
=true},
78 func
= function(name
, param
)
80 local nodestring
= nil
81 p
.x
, p
.y
, p
.z
, nodestring
= param
:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) +(.+)$")
82 p
.x
, p
.y
, p
.z
= tonumber(p
.x
), tonumber(p
.y
), tonumber(p
.z
)
83 if p
.x
and p
.y
and p
.z
and nodestring
then
84 local itemstack
= ItemStack(nodestring
)
85 if itemstack
:is_empty() or not minetest
.registered_nodes
[itemstack
:get_name()] then
86 return false, S("Invalid node")
88 minetest
.set_node(p
, {name
=nodestring
})
89 return true, S("@1 spawned.", nodestring
)
91 return false, S("Invalid parameters (see /help setblock)")
95 minetest
.register_chatcommand("list", {
96 description
= "Show who is logged on",
101 for _
, player
in ipairs(minetest
.get_connected_players()) do
102 players
= players
..player
:get_player_name().."\n"
104 minetest
.chat_send_player(name
, players
)
108 minetest
.register_chatcommand("seed", {
109 description
= "Displays the world seed",
112 func
= function(name
)
113 minetest
.chat_send_player(name
, minetest
.get_mapgen_setting("seed"))
117 local function register_chatcommand_alias(alias
, cmd
)
118 local def
= minetest
.chatcommands
[cmd
]
119 minetest
.register_chatcommand(alias
, def
)
122 if minecraftaliases
then
123 register_chatcommand_alias("?", "help")
124 register_chatcommand_alias("who", "list")
125 register_chatcommand_alias("pardon", "unban")
126 register_chatcommand_alias("stop", "shutdown")
127 register_chatcommand_alias("summon", "spawnentity")
128 register_chatcommand_alias("tell", "msg")
129 register_chatcommand_alias("w", "msg")
130 register_chatcommand_alias("tp", "teleport")
131 register_chatcommand_alias("clear", "clearinv")
133 minetest
.register_chatcommand("banlist", {
134 description
= S("List bans"),
135 privs
= minetest
.chatcommands
["ban"].privs
,
136 func
= function(name
)
137 return true, S("Ban list: @1", core
.get_ban_list())