From 910b3d57ac9c8a9f42c178bc04fc41f65c5d0705 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Mon, 31 Oct 2022 16:19:38 +0100 Subject: [PATCH 1/4] fix crash iteself --- mods/HUD/awards/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HUD/awards/api.lua b/mods/HUD/awards/api.lua index 059f6b287..2bbea3c9b 100644 --- a/mods/HUD/awards/api.lua +++ b/mods/HUD/awards/api.lua @@ -484,7 +484,7 @@ function awards.show_to(name, to, sid, text) name = to end if name == to and awards.player(to).disabled then - minetest.chat_send_player(S("You've disabled awards. Type /awards enable to reenable.")) + minetest.chat_send_player(name,S("You've disabled awards. Type /awards enable to reenable.")) return end if text then From c1af4935a12803d323b529faa8b2aee1b14f0b4b Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Mon, 31 Oct 2022 16:22:28 +0100 Subject: [PATCH 2/4] improve my poor (old) fix --- mods/HUD/awards/chat_commands.lua | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/mods/HUD/awards/chat_commands.lua b/mods/HUD/awards/chat_commands.lua index 7ae15755e..88af4962b 100644 --- a/mods/HUD/awards/chat_commands.lua +++ b/mods/HUD/awards/chat_commands.lua @@ -20,14 +20,15 @@ minetest.register_chatcommand("awards", { params = S("[c|clear|disable|enable]"), description = S("Show, clear, disable or enable your advancements."), func = function(name, param) + if awards.player(name).disabled then + minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!")) + return + end + if param == "clear" 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.clear_player(name) - minetest.chat_send_player(name, - S("All your awards and statistics have been cleared. You can now start again.")) - end + awards.clear_player(name) + minetest.chat_send_player(name, + S("All your awards and statistics have been cleared. You can now start again.")) elseif param == "disable" then awards.disable(name) minetest.chat_send_player(name, S("You have disabled your advancements.")) @@ -35,17 +36,9 @@ minetest.register_chatcommand("awards", { awards.enable(name) minetest.chat_send_player(name, S("You have enabled your advancements.")) 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) - end + awards.show_to(name, name, nil, true) 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 - awards.show_to(name, name, nil, false) - end + awards.show_to(name, name, nil, false) end end }) From c572c27326456eaf45fb9ef38d60bd9918b456d4 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Mon, 31 Oct 2022 21:40:38 +0000 Subject: [PATCH 3/4] implement suggestions by cora (https://is.gd/jJRf3y) --- mods/HUD/awards/chat_commands.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/HUD/awards/chat_commands.lua b/mods/HUD/awards/chat_commands.lua index 88af4962b..b15668822 100644 --- a/mods/HUD/awards/chat_commands.lua +++ b/mods/HUD/awards/chat_commands.lua @@ -20,6 +20,11 @@ minetest.register_chatcommand("awards", { params = S("[c|clear|disable|enable]"), description = S("Show, clear, disable or enable your advancements."), func = function(name, param) + if param == "enable" then + awards.enable(name) + minetest.chat_send_player(name, S("You have enabled your advancements.")) + end + if awards.player(name).disabled then minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!")) return @@ -32,13 +37,8 @@ minetest.register_chatcommand("awards", { elseif param == "disable" then awards.disable(name) minetest.chat_send_player(name, S("You have disabled your advancements.")) - elseif param == "enable" then - awards.enable(name) - minetest.chat_send_player(name, S("You have enabled your advancements.")) - elseif param == "c" then + else param == "c" then awards.show_to(name, name, nil, true) - else - awards.show_to(name, name, nil, false) end end }) From e9703c409ea1da90b44428f00c83a8a0d3d8959e Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Mon, 31 Oct 2022 21:53:51 +0000 Subject: [PATCH 4/4] correct if/else in line 42 --- mods/HUD/awards/chat_commands.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/HUD/awards/chat_commands.lua b/mods/HUD/awards/chat_commands.lua index b15668822..04371139f 100644 --- a/mods/HUD/awards/chat_commands.lua +++ b/mods/HUD/awards/chat_commands.lua @@ -23,6 +23,7 @@ minetest.register_chatcommand("awards", { if param == "enable" then awards.enable(name) minetest.chat_send_player(name, S("You have enabled your advancements.")) + return end if awards.player(name).disabled then @@ -37,8 +38,8 @@ minetest.register_chatcommand("awards", { elseif param == "disable" then awards.disable(name) minetest.chat_send_player(name, S("You have disabled your advancements.")) - else param == "c" then - awards.show_to(name, name, nil, true) + else + awards.show_to(name, name, nil, false) end end })