Extend inventory action logging to include bones (#3040)

This commit is contained in:
imre84 2023-07-05 23:14:02 +02:00 committed by GitHub
parent 16bf166902
commit d86435d86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -28,7 +28,7 @@ local bones_formspec =
local share_bones_time = tonumber(minetest.settings:get("share_bones_time")) or 1200
local share_bones_time_early = tonumber(minetest.settings:get("share_bones_time_early")) or share_bones_time / 4
minetest.register_node("bones:bones", {
local bones_def = {
description = S("Bones"),
tiles = {
"bones_top.png^[transform2",
@ -130,7 +130,11 @@ minetest.register_node("bones:bones", {
end,
on_blast = function(pos)
end,
})
}
default.set_inventory_action_loggers(bones_def, "bones")
minetest.register_node("bones:bones", bones_def)
local function may_replace(pos, player)
local node_name = minetest.get_node(pos).name

View File

@ -754,12 +754,12 @@ function default.set_inventory_action_loggers(def, name)
end
local on_put = def.on_metadata_inventory_put or nop
def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
default.log_player_action(player, "moves", stack:get_name(), "to", name, "at", pos)
default.log_player_action(player, "moves", stack:get_name(), stack:get_count(), "to", name, "at", pos)
return on_put(pos, listname, index, stack, player)
end
local on_take = def.on_metadata_inventory_take or nop
def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
default.log_player_action(player, "takes", stack:get_name(), "from", name, "at", pos)
default.log_player_action(player, "takes", stack:get_name(), stack:get_count(), "from", name, "at", pos)
return on_take(pos, listname, index, stack, player)
end
end