From e890a2002f2af883c4d8a581185efd1fb2a20a1d Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Thu, 29 Feb 2024 21:57:38 +0100 Subject: [PATCH] Pipeworks compatibility: Canning Machine --- compat/pipeworks.lua | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/compat/pipeworks.lua b/compat/pipeworks.lua index 1803d60..85cd2ae 100644 --- a/compat/pipeworks.lua +++ b/compat/pipeworks.lua @@ -334,3 +334,69 @@ override.groups=minetest.registered_nodes["industrialtest:mfsu"].groups override.groups.tubedevice=1 override.groups.tubedevice_receiver=1 minetest.override_item("industrialtest:mfsu",override) + +-- Canning Machine +def=table.copy(minetest.registered_nodes["industrialtest:canning_machine"]) + +def.groups.tubedevice=1 +def.groups.tubedevice_receiver=1 + +override={ + groups=def.groups, + tube={ + insert_object=function(pos,node,stack,direction) + local listname + if direction.y==1 then + listname="powerStorage" + elseif direction.y==-1 then + listname="fuel" + else + listname="target" + end + local def=stack:get_definition() + if (listname=="powerStorage" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or + (listname=="fuel" and (not def.groups or not def.groups._industrialtest_fuel)) or + (listname=="target" and (not def.groups or not def.groups._industrialtest_fueled)) then + return nil + end + local meta=minetest.get_meta(pos) + local inv=meta:get_inventory() + local result=inv:add_item(listname,stack) + minetest.get_node_timer(pos):start(industrialtest.updateDelay) + return result + end, + can_insert=function(pos,node,stack,direction) + local listname + if direction.y==1 then + listname="powerStorage" + elseif direction.y==-1 then + listname="fuel" + else + listname="target" + end + local def=stack:get_definition() + if (listname=="powerStorage" and not industrialtest.api.hasPowerStorage(stack:get_meta())) or + (listname=="fuel" and (not def.groups or not def.groups._industrialtest_fuel)) or + (listname=="target" and (not def.groups or not def.groups._industrialtest_fueled)) then + return false + end + local meta=minetest.get_meta(pos) + local inv=meta:get_inventory() + return inv:room_for_item(listname,stack) + end, + input_inventory="target", + connect_sides={ + left=1, + right=1, + back=1, + bottom=1, + top=1 + } + }, + after_place_node=pipeworks.after_place, + after_dig_node=pipeworks.after_dig, + on_rotate=pipeworks.on_rotate +} + +minetest.override_item("industrialtest:canning_machine",override) +minetest.override_item("industrialtest:canning_machine_active",override)