1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-11-16 06:50:18 +01:00

add default.log_action function

This commit is contained in:
nixnoxus 2022-03-30 23:57:08 +02:00
parent 659895c3ed
commit 876a2f7cef
4 changed files with 19 additions and 22 deletions

View File

@ -224,18 +224,13 @@ function default.chest.register_chest(prefixed_name, d)
def.on_metadata_inventory_move = function(pos, from_list, from_index, def.on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player) to_list, to_index, count, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "moves stuff in chest")
" moves stuff in chest at " .. minetest.pos_to_string(pos))
end end
def.on_metadata_inventory_put = function(pos, listname, index, stack, player) def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "moves " .. stack:get_name() .. " to chest")
" moves " .. stack:get_name() ..
" to chest at " .. minetest.pos_to_string(pos))
end end
def.on_metadata_inventory_take = function(pos, listname, index, stack, player) def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "takes " .. stack:get_name() .. " from chest")
" takes " .. stack:get_name() ..
" from chest at " .. minetest.pos_to_string(pos))
end end
local def_opened = table.copy(def) local def_opened = table.copy(def)

View File

@ -717,8 +717,8 @@ end
-- --
-- NOTICE: This method is not an official part of the API yet. -- NOTICE: This methods are not an official part of the API yet.
-- This method may change in future. -- This methods may change in future.
-- --
function default.can_interact_with_node(player, pos) function default.can_interact_with_node(player, pos)
@ -757,3 +757,11 @@ function default.can_interact_with_node(player, pos)
return false return false
end end
function default.log_action(player, pos, message)
-- only log actions of real players
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))
end
end

View File

@ -2551,18 +2551,15 @@ minetest.register_node("default:bookshelf", {
return 0 return 0
end, end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "moves stuff in bookshelf")
" moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
update_bookshelf(pos) update_bookshelf(pos)
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "puts stuff to bookshelf")
" puts stuff to bookshelf at " .. minetest.pos_to_string(pos))
update_bookshelf(pos) update_bookshelf(pos)
end, end,
on_metadata_inventory_take = function(pos, listname, index, stack, player) on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "takes stuff from bookshelf")
" takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
update_bookshelf(pos) update_bookshelf(pos)
end, end,
on_blast = function(pos) on_blast = function(pos)

View File

@ -75,18 +75,15 @@ minetest.register_node("vessels:shelf", {
return 0 return 0
end, end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "moves stuff in vessels shelf")
" moves stuff in vessels shelf at ".. minetest.pos_to_string(pos))
update_vessels_shelf(pos) update_vessels_shelf(pos)
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "moves stuff to vessels shelf")
" moves stuff to vessels shelf at ".. minetest.pos_to_string(pos))
update_vessels_shelf(pos) update_vessels_shelf(pos)
end, end,
on_metadata_inventory_take = function(pos, listname, index, stack, player) on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() .. default.log_action(player, pos, "takes stuff from vessels shelf")
" takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))
update_vessels_shelf(pos) update_vessels_shelf(pos)
end, end,
on_blast = function(pos) on_blast = function(pos)