Skip to content

Commit

Permalink
Extend inventory action logging to include bones (#3040)
Browse files Browse the repository at this point in the history
  • Loading branch information
imre84 authored Jul 5, 2023
1 parent 16bf166 commit d86435d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions mods/bones/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mods/default/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d86435d

Please sign in to comment.