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.
18 if minetest
.get_modpath("intllib") then
21 S
= function ( s
) return s
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
34 minetest
.chat_send_player(name
, S("You have disabled your achievements."))
35 elseif param
== "enable" then
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)
41 awards
.show_to(name
, name
, nil, false)
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
]
52 minetest
.chat_send_player(name
, string.format(S("%s: %s"), def
.title
, def
.description
))
54 minetest
.chat_send_player(name
, S("Achievement not found."))
59 minetest
.register_chatcommand("awpl", {
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
69 minetest
.chat_send_player(name
, param
)
70 local player
= awards
.player(param
)
71 minetest
.chat_send_player(name
, dump(player
))