`default.log_player_action` accepts pos as table
This commit is contained in:
parent
1ba876893d
commit
a6d940abda
|
@ -1136,7 +1136,7 @@ the log.
|
||||||
* `player` The player who performed the action
|
* `player` The player who performed the action
|
||||||
* `message_parts` Any mumber of message parts describing the action
|
* `message_parts` Any mumber of message parts describing the action
|
||||||
in 3rd person singular present tense. It can also
|
in 3rd person singular present tense. It can also
|
||||||
contain a `vector` which is logged as "(X,Y,Z)"
|
contain a `pos` which is logged as "(X,Y,Z)"
|
||||||
|
|
||||||
`default.set_inventory_action_loggers(def, name)`
|
`default.set_inventory_action_loggers(def, name)`
|
||||||
|
|
||||||
|
|
|
@ -721,6 +721,11 @@ end
|
||||||
|
|
||||||
local log_non_player_actions = minetest.settings:get_bool("log_non_player_actions", false)
|
local log_non_player_actions = minetest.settings:get_bool("log_non_player_actions", false)
|
||||||
|
|
||||||
|
local is_pos = function(v)
|
||||||
|
return type(v) == "table" and
|
||||||
|
type(v.x) == "number" and type(v.y) == "number" and type(v.z) == "number"
|
||||||
|
end
|
||||||
|
|
||||||
function default.log_player_action(player, ...)
|
function default.log_player_action(player, ...)
|
||||||
local msg = player:get_player_name()
|
local msg = player:get_player_name()
|
||||||
if player.is_fake_player or not player:is_player() then
|
if player.is_fake_player or not player:is_player() then
|
||||||
|
@ -732,7 +737,7 @@ function default.log_player_action(player, ...)
|
||||||
end
|
end
|
||||||
for _, v in ipairs({...}) do
|
for _, v in ipairs({...}) do
|
||||||
-- translate pos
|
-- translate pos
|
||||||
local part = vector.check(v) and minetest.pos_to_string(v) or v
|
local part = is_pos(v) and minetest.pos_to_string(v) or v
|
||||||
-- no leading spaces before punctuation marks
|
-- no leading spaces before punctuation marks
|
||||||
msg = msg .. (string.match(part, "^[;,.]") and "" or " ") .. part
|
msg = msg .. (string.match(part, "^[;,.]") and "" or " ") .. part
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue