Rename mobs mod to mcl_mobs
[MineClone/MineClone2.git] / mods / HUD / awards / chat_commands.lua
blobc386c19cb55b9438f18952a80ad58fdfd1e13a80
1 -- AWARDS
2 --
3 -- Copyright (C) 2013-2015 rubenwardy
4 -- This program is free software; you can redistribute it and/or modify
5 -- it under the terms of the GNU Lesser General Public License as published by
6 -- the Free Software Foundation; either version 2.1 of the License, or
7 -- (at your option) any later version.
8 -- This program is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 -- GNU Lesser General Public License for more details.
12 -- You should have received a copy of the GNU Lesser General Public License along
13 -- with this program; if not, write to the Free Software Foundation, Inc.,
14 -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 local S
18 if minetest.get_modpath("intllib") then
19 S = intllib.Getter()
20 else
21 S = function ( s ) return s end
22 end
24 minetest.register_chatcommand("awards", {
25 params = S("[c|clear|disable|enable]"),
26 description = S("Show, clear, disable or enable your achievements"),
27 func = function(name, param)
28 if param == "clear" then
29 awards.clear_player(name)
30 minetest.chat_send_player(name,
31 S("All your awards and statistics have been cleared. You can now start again."))
32 elseif param == "disable" then
33 awards.disable(name)
34 minetest.chat_send_player(name, S("You have disabled your achievements."))
35 elseif param == "enable" then
36 awards.enable(name)
37 minetest.chat_send_player(name, S("You have enabled your achievements."))
38 elseif param == "c" then
39 awards.show_to(name, name, nil, true)
40 else
41 awards.show_to(name, name, nil, false)
42 end
43 end
46 minetest.register_chatcommand("awd", {
47 params = S("<achievement ID>"),
48 description = S("Show details of an achievement"),
49 func = function(name, param)
50 local def = awards.def[param]
51 if def then
52 minetest.chat_send_player(name, string.format(S("%s: %s"), def.title, def.description))
53 else
54 minetest.chat_send_player(name, S("Achievement not found."))
55 end
56 end
59 minetest.register_chatcommand("awpl", {
60 privs = {
61 server = true
63 params = S("<name>"),
64 description = S("Get the achievements statistics for the given player or yourself"),
65 func = function(name, param)
66 if not param or param == "" then
67 param = name
68 end
69 minetest.chat_send_player(name, param)
70 local player = awards.player(param)
71 minetest.chat_send_player(name, dump(player))
72 end