From a56113ca145c90dba8aa46b4fead6b70381d3349 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 15 Jun 2022 22:39:35 +0200 Subject: [PATCH] Show achievement msg to achiever only (sett' add') --- mods/rp_achievements/init.lua | 12 ++++++++---- settingtypes.txt | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mods/rp_achievements/init.lua b/mods/rp_achievements/init.lua index 4618e3b..79b1921 100644 --- a/mods/rp_achievements/init.lua +++ b/mods/rp_achievements/init.lua @@ -3,6 +3,7 @@ -- local COLOR_GOTTEN = "#00FF00" +local COLOR_GOTTEN_MSG = "#00FF00" local S = minetest.get_translator("rp_achievements") @@ -175,22 +176,25 @@ local function check_achievement_gotten(player, aname) minetest.after( 2.0, function(name, aname) - if not minetest.is_singleplayer() then + local notify_all = minetest.settings:get_bool("rp_achievements_notify_all", false) + if notify_all and (not minetest.is_singleplayer()) then + -- Notify all players minetest.chat_send_all( minetest.colorize( - "#0f0", + COLOR_GOTTEN_MSG, "*** " .. S("@1 has earned the achievement “@2”.", name, achievements.registered_achievements[aname].title))) else + -- Only notify the player who got the achievement minetest.chat_send_player(name, minetest.colorize( - "#0f0", + COLOR_GOTTEN_MSG, "*** " .. S("You have earned the achievement “@1”.", achievements.registered_achievements[aname].title))) end - minetest.log("action", "[rp_achievements] " .. name .. " got achievement '"..aname.."'") end, name, aname) + minetest.log("action", "[rp_achievements] " .. name .. " got achievement '"..aname.."'") end if rp_formspec.current_page[name] == "rp_achievements:achievements" then diff --git a/settingtypes.txt b/settingtypes.txt index 64a0f5c..cda0732 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -3,8 +3,6 @@ ## Menu settings for this game ## -## Multiplayer settings - [Player] # If enabled, players drop their items when they die. drop_items_on_die (Drop items on death) bool true @@ -28,6 +26,11 @@ hunger_enable (Enable hunger) bool true # which is really fast! hunger_step (Hunger frequency) float 3.0 0.0 +# If enabled, all players will get a notification in chat when a player +# earned an achievement. If disabled, only the achiever will get a +# notification. +rp_achievements_notify_all (Announce achievements to all) bool false + [World] # If enabled, the weather will change from time to time. weather_enable (Enable dynamic weather) bool true