From eb162e6c2951c9e76f38b8157b40c3665fb5334a Mon Sep 17 00:00:00 2001 From: nixnoxus Date: Sat, 2 Apr 2022 11:29:44 +0200 Subject: [PATCH] appgurueu's comments implemented --- game_api.txt | 2 +- mods/default/functions.lua | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/game_api.txt b/game_api.txt index 3b4efa06..4e2bae29 100644 --- a/game_api.txt +++ b/game_api.txt @@ -1127,7 +1127,7 @@ setting `enable_non_player_action_log` is enabled. `default.log_action(player, pos, message)` - * `player` The player who performed the action, may be `nil` + * `player` The player who performed the action * `pos` Position of the node at which the action was performed * `message` A message describing the action diff --git a/mods/default/functions.lua b/mods/default/functions.lua index f2811750..282baa7e 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -758,20 +758,17 @@ 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 +local non_player_action_log = minetest.settings:get_bool("enable_non_player_action_log") ~= false function default.log_action(player, pos, message) - local who = player and player:get_player_name() or "(something)" - if player and not player.is_fake_player and player:is_player() then + local who = player:get_player_name() + if not player.is_fake_player and player:is_player() then -- log action of real player minetest.log("action", who .. " " .. message .. " at " .. minetest.pos_to_string(pos)) - elseif non_player_action_log ~= false then + elseif non_player_action_log 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 + who = who .. "(" .. (type(player.is_fake_player) == "string" + and player.is_fake_player or "*").. ")" minetest.log("action", who .. " " .. message .. " at " .. minetest.pos_to_string(pos)) end end