From 61db871d3f30fbf5257b95d1ad4e89e2b19636eb Mon Sep 17 00:00:00 2001 From: Louis <55180044+louisroyer@users.noreply.github.com> Date: Sat, 6 Mar 2021 17:58:27 +0100 Subject: [PATCH] Insertion with vacuum pipes Insertion is now done into the wifi-chest of the player who placed the wifi chest when the item to be inserted has no owner yet (otherwise, it is inserted into the wifi-chest of the player who own the item). --- models/wifi.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/models/wifi.lua b/models/wifi.lua index 669fbf1..506bac9 100644 --- a/models/wifi.lua +++ b/models/wifi.lua @@ -22,10 +22,18 @@ wifi.can_dig = function(pos, player) return true end -- pipeworks support (we need to override what is created by gen_def because too generic) wifi.tube = pipeworks_enabled and { insert_object = function(pos, node, stack, direction, owner) + local wifi_chest_owner if not owner then - return stack + local wifi_chest = minetest.get_meta(pos) + if not wifi_chest then + return stack + end + wifi_chest_owner = wifi_chest:get_string("owner") + if not wifi_chest_owner then + return stack + end end - local player = minetest.get_player_by_name(owner) + local player = minetest.get_player_by_name(owner or wifi_chest_owner) if not player then return stack end @@ -33,10 +41,18 @@ wifi.tube = pipeworks_enabled and { return inv:add_item("more_chests:wifi", stack) end, can_insert = function(pos, node, stack, direction, owner) + local wifi_chest_owner if not owner then - return false + local wifi_chest = minetest.get_meta(pos) + if not wifi_chest then + return stack + end + wifi_chest_owner = wifi_chest:get_string("owner") + if not wifi_chest_owner then + return false + end end - local player = minetest.get_player_by_name(owner) + local player = minetest.get_player_by_name(owner or wifi_chest_owner) if not player then return false end