improve my poor (old) fix

This commit is contained in:
chmodsayshello 2022-10-31 16:22:28 +01:00
parent 910b3d57ac
commit c1af4935a1

View File

@ -20,14 +20,15 @@ minetest.register_chatcommand("awards", {
params = S("[c|clear|disable|enable]"), params = S("[c|clear|disable|enable]"),
description = S("Show, clear, disable or enable your advancements."), description = S("Show, clear, disable or enable your advancements."),
func = function(name, param) func = function(name, param)
if param == "clear" then if awards.player(name).disabled then
if awards.player(name).disabled ~= nil then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!")) minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
else return
end
if param == "clear" then
awards.clear_player(name) awards.clear_player(name)
minetest.chat_send_player(name, minetest.chat_send_player(name,
S("All your awards and statistics have been cleared. You can now start again.")) S("All your awards and statistics have been cleared. You can now start again."))
end
elseif param == "disable" then elseif param == "disable" then
awards.disable(name) awards.disable(name)
minetest.chat_send_player(name, S("You have disabled your advancements.")) minetest.chat_send_player(name, S("You have disabled your advancements."))
@ -35,19 +36,11 @@ minetest.register_chatcommand("awards", {
awards.enable(name) awards.enable(name)
minetest.chat_send_player(name, S("You have enabled your advancements.")) minetest.chat_send_player(name, S("You have enabled your advancements."))
elseif param == "c" then elseif param == "c" then
if awards.player(name).disabled ~= nil then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
else
awards.show_to(name, name, nil, true) awards.show_to(name, name, nil, true)
end
else
if awards.player(name).disabled ~= nil then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
else else
awards.show_to(name, name, nil, false) awards.show_to(name, name, nil, false)
end end
end end
end
}) })
minetest.register_privilege("advancements", { minetest.register_privilege("advancements", {