diff --git a/technic/machines/HV/nuclear_reactor.lua b/technic/machines/HV/nuclear_reactor.lua index 8d440e6a..d78abec9 100644 --- a/technic/machines/HV/nuclear_reactor.lua +++ b/technic/machines/HV/nuclear_reactor.lua @@ -480,6 +480,9 @@ minetest.register_node("technic:hv_nuclear_reactor_core", { allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, technic_run = run, }) @@ -521,6 +524,9 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", { allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, technic_run = run, technic_on_disable = function(pos, node) local timer = minetest.get_node_timer(pos) diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index 83a3d736..f6bfb7ef 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -554,6 +554,9 @@ minetest.register_node("technic:quarry", { allow_metadata_inventory_take = function(pos, listname, index, stack, player) return player_allowed(pos, player:get_player_name()) and stack:get_count() or 0 end, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, mesecons = { effector = { action_on = function(pos) diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua index d8e17e8d..04963060 100644 --- a/technic/machines/MV/tool_workshop.lua +++ b/technic/machines/MV/tool_workshop.lua @@ -131,6 +131,9 @@ minetest.register_node("technic:tool_workshop", { can_dig = technic.machine_can_dig, allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, tube = { can_insert = function (pos, node, stack, direction) return minetest.get_meta(pos):get_inventory():room_for_item("src", stack) diff --git a/technic/machines/other/coal_alloy_furnace.lua b/technic/machines/other/coal_alloy_furnace.lua index 7de7f93c..89ce4f82 100644 --- a/technic/machines/other/coal_alloy_furnace.lua +++ b/technic/machines/other/coal_alloy_furnace.lua @@ -72,6 +72,9 @@ minetest.register_node("technic:coal_alloy_furnace", { allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, }) minetest.register_node("technic:coal_alloy_furnace_active", { @@ -92,6 +95,9 @@ minetest.register_node("technic:coal_alloy_furnace_active", { allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, }) minetest.register_abm({ diff --git a/technic/machines/other/constructor.lua b/technic/machines/other/constructor.lua index 42e45553..5536c1d4 100644 --- a/technic/machines/other/constructor.lua +++ b/technic/machines/other/constructor.lua @@ -205,6 +205,9 @@ local function make_constructor(mark, length) allow_metadata_inventory_put = allow_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, on_rotate = function(pos, node, user, mode, new_param2) if mode ~= 1 then return false @@ -231,6 +234,9 @@ local function make_constructor(mark, length) allow_metadata_inventory_put = allow_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, on_rotate = false }) end diff --git a/technic/machines/other/injector.lua b/technic/machines/other/injector.lua index d2fc0df4..d91e4eca 100644 --- a/technic/machines/other/injector.lua +++ b/technic/machines/other/injector.lua @@ -152,6 +152,9 @@ minetest.register_node("technic:injector", { allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, after_place_node = pipeworks.after_place, after_dig_node = pipeworks.after_dig }) diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua index 67e981ed..f9396f78 100644 --- a/technic/machines/register/battery_box.lua +++ b/technic/machines/register/battery_box.lua @@ -389,6 +389,9 @@ function technic.register_battery_box(nodename, data) allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, technic_run = run, on_timer = on_timer, on_rightclick = function(pos) update_node(pos, true) end, diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua index 440f3df7..9d874cc2 100644 --- a/technic/machines/register/common.lua +++ b/technic/machines/register/common.lua @@ -190,3 +190,31 @@ function technic.machine_inventory_move(pos, from_list, from_index, local stack = minetest.get_meta(pos):get_inventory():get_stack(from_list, from_index) return inv_change(pos, player, count, from_list, to_list, stack) end + +function technic.machine_on_inventory_put(pos, listname, index, stack, player) + minetest.log("action", string.format("%s puts %s into %s at %s", + player:get_player_name(), + stack:to_string(), + minetest.get_node(pos).name, + minetest.pos_to_string(pos) + )) +end + +function technic.machine_on_inventory_take(pos, listname, index, stack, player) + minetest.log("action", string.format("%s takes %s from %s at %s", + player:get_player_name(), + stack:to_string(), + minetest.get_node(pos).name, + minetest.pos_to_string(pos) + )) +end + +function technic.machine_on_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) + local stack = minetest.get_meta(pos):get_inventory():get_stack(to_list, to_index) + minetest.log("action", string.format("%s moves %s in %s at %s", + player:get_player_name(), + stack:to_string(), + minetest.get_node(pos).name, + minetest.pos_to_string(pos) + )) +end diff --git a/technic/machines/register/machine_base.lua b/technic/machines/register/machine_base.lua index 14fd0c14..0ae8d819 100644 --- a/technic/machines/register/machine_base.lua +++ b/technic/machines/register/machine_base.lua @@ -216,6 +216,9 @@ function technic.register_base_machine(nodename, data) allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, technic_run = run, after_place_node = def.tube and pipeworks.after_place, after_dig_node = technic.machine_after_dig_node, @@ -265,6 +268,9 @@ function technic.register_base_machine(nodename, data) allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_take = technic.machine_inventory_take, allow_metadata_inventory_move = technic.machine_inventory_move, + on_metadata_inventory_move = technic.machine_on_inventory_move, + on_metadata_inventory_put = technic.machine_on_inventory_put, + on_metadata_inventory_take = technic.machine_on_inventory_take, technic_run = run, technic_disabled_machine_name = nodename, on_receive_fields = function(pos, formname, fields, sender) diff --git a/technic_chests/inventory.lua b/technic_chests/inventory.lua index d338b7d6..46da9cab 100644 --- a/technic_chests/inventory.lua +++ b/technic_chests/inventory.lua @@ -176,3 +176,18 @@ function technic.chests.log_inv_change(pos, name, change, items) minetest.log("action", name.." takes "..items.." from chest at "..spos) end end + +function technic.chests.log_fast_move(pos, name, change, items) + local spos = minetest.pos_to_string(pos) + local itemlist = {} + for _, stack in ipairs(items) do + table.insert(itemlist, stack.name.." "..stack.count) + end + if change == "put" then + minetest.log("action", string.format("%s puts items into chest at %s: %s", + name, spos, table.concat(itemlist, ", "))) + elseif change == "take" then + minetest.log("action", string.format("%s takes items from chest at %s: %s", + name, spos, table.concat(itemlist, ", "))) + end +end diff --git a/technic_chests/register.lua b/technic_chests/register.lua index 8035275c..f7dd2533 100644 --- a/technic_chests/register.lua +++ b/technic_chests/register.lua @@ -144,7 +144,7 @@ function technic.chests.register_chest(nodename, data) if data.digilines and meta:get_int("send_take") == 1 then technic.chests.send_digiline_message(pos, "take", player, moved_items) end - technic.chests.log_inv_change(pos, player:get_player_name(), "take", "stuff") + technic.chests.log_fast_move(pos, player:get_player_name(), "take", moved_items) return 0 end return count @@ -160,7 +160,7 @@ function technic.chests.register_chest(nodename, data) if data.digilines and meta:get_int("send_put") == 1 then technic.chests.send_digiline_message(pos, "put", player, moved_items) end - technic.chests.log_inv_change(pos, player:get_player_name(), "put", "stuff") + technic.chests.log_fast_move(pos, player:get_player_name(), "put", moved_items) return 0 end return stack:get_count() diff --git a/technic_cnc/api.lua b/technic_cnc/api.lua index 9a0128f1..0865780a 100644 --- a/technic_cnc/api.lua +++ b/technic_cnc/api.lua @@ -383,6 +383,11 @@ function technic_cnc.register_cnc_machine(nodename, def) groups.tubedevice_receiver = 1 end + -- Only do logging when technic is enabled to avoid duplicating code + local on_metadata_inventory_move = technic_cnc.use_technic and technic.machine_on_inventory_move or nil + local on_metadata_inventory_put = technic_cnc.use_technic and technic.machine_on_inventory_put or nil + local on_metadata_inventory_take = technic_cnc.use_technic and technic.machine_on_inventory_take or nil + -- Inactive state CNC machine minetest.register_node(":" .. nodename, { description = def.description, @@ -412,6 +417,9 @@ function technic_cnc.register_cnc_machine(nodename, def) allow_metadata_inventory_put = def.allow_metadata_inventory_put or allow_metadata_inventory_put, allow_metadata_inventory_take = def.allow_metadata_inventory_take or allow_metadata_inventory_take, allow_metadata_inventory_move = def.allow_metadata_inventory_move or allow_metadata_inventory_move, + on_metadata_inventory_move = on_metadata_inventory_move, + on_metadata_inventory_put = on_metadata_inventory_put, + on_metadata_inventory_take = on_metadata_inventory_take, on_receive_fields = on_receive_fields, technic_run = def.technic_run or technic_run, }) @@ -436,6 +444,9 @@ function technic_cnc.register_cnc_machine(nodename, def) allow_metadata_inventory_put = def.allow_metadata_inventory_put or allow_metadata_inventory_put, allow_metadata_inventory_take = def.allow_metadata_inventory_take or allow_metadata_inventory_take, allow_metadata_inventory_move = def.allow_metadata_inventory_move or allow_metadata_inventory_move, + on_metadata_inventory_move = on_metadata_inventory_move, + on_metadata_inventory_put = on_metadata_inventory_put, + on_metadata_inventory_take = on_metadata_inventory_take, on_receive_fields = on_receive_fields, technic_run = def.technic_run or technic_run, technic_disabled_machine_name = nodename,