diff --git a/minetest.conf.example b/minetest.conf.example index 86eba660..7766230d 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -75,3 +75,6 @@ default:torch 99,default:cobble 99 # Enable cloud variation by the 'weather' mod. # Non-functional in V6 or Singlenode mapgens. #enable_weather = true + +# If enabled, non-player actions are logged +#enable_non_player_action_log = false diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 4ff00421..f2811750 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -758,11 +758,21 @@ function default.can_interact_with_node(player, pos) return false end +local non_player_action_log = minetest.settings:get_bool("enable_non_player_action_log") or false + function default.log_action(player, pos, message) - -- only log actions of real players + local who = player and player:get_player_name() or "(something)" if player and not player.is_fake_player and player:is_player() then - minetest.log("action", player:get_player_name() .. - " " .. message .. " at " .. minetest.pos_to_string(pos)) + -- log action of real player + minetest.log("action", who .. " " .. message .. " at " .. minetest.pos_to_string(pos)) + elseif non_player_action_log ~= false then + -- log action of non real player + if player and player.is_fake_player and type(player.is_fake_player) == "string" then + who = who .. "(" .. player.is_fake_player .. ")" + else + who = who .. "(*)" + end + minetest.log("action", who .. " " .. message .. " at " .. minetest.pos_to_string(pos)) end end diff --git a/settingtypes.txt b/settingtypes.txt index eff1e902..11ec8b57 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -75,3 +75,6 @@ river_source_sounds (River source node sounds) bool false # Enable cloud variation by the 'weather' mod. # Non-functional in V6 or Singlenode mapgens. enable_weather (Enable weather) bool true + +# If enabled, non-player actions are logged +enable_non_player_action_log (Log non-player action) bool false