diff --git a/machines.lua b/machines.lua index 83e11e9..ee3e3b9 100644 --- a/machines.lua +++ b/machines.lua @@ -490,12 +490,15 @@ local function registerSimpleElectricItemProcessor(config) local meta=minetest.get_meta(pos) local inv=meta:get_inventory() local srcSlot=inv:get_stack("src",1) + local dstSlot=inv:get_stack("dst",1) if fromList=="src" and count==srcSlot:get_count() then meta:set_float("srcTime",-1) meta:set_float("maxSrcTime",0) if meta:get_int("industrialtest.powerAmount")>0 then meta:set_string("formspec",getFormspec(meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100,meta:get_float("srcTime")/meta:get_float("maxSrcTime")*100)) end + elseif fromList=="dst" and dstSlot:get_free_space()==0 then + minetest.get_node_timer(pos):start(industrialtest.updateDelay) end end, on_metadata_inventory_put=function(pos,listname) @@ -507,16 +510,24 @@ local function registerSimpleElectricItemProcessor(config) local meta=minetest.get_meta(pos) local inv=meta:get_inventory() local srcSlot=inv:get_stack("src",1) + local dstSlot=inv:get_stack("dst",1) if listname=="src" and stack:get_count()==srcSlot:get_count() then meta:set_float("srcTime",-1) meta:set_float("maxSrcTime",0) if meta:get_int("industrialtest.powerAmount")>0 then meta:set_string("formspec",getFormspec(meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100,meta:get_float("srcTime")/meta:get_float("maxSrcTime")*100)) end + elseif listname=="dst" and dstSlot:get_free_space()==0 then + minetest.get_node_timer(pos):start(industrialtest.updateDelay) end end, _industrialtest_updateFormspec=function(meta) meta:set_string("formspec",getFormspec(meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100,meta:get_float("srcTime")/meta:get_float("maxSrcTime")*100)) + end, + _industrialtest_onPowerFlow=function(pos) + -- FIXME: this probably will require refactor so node timer won't be started + -- just to test if machine can process item + minetest.get_node_timer(pos):start(industrialtest.updateDelay) end } if industrialtest.mtgAvailable then @@ -757,12 +768,15 @@ definition={ local meta=minetest.get_meta(pos) local inv=meta:get_inventory() local srcSlot=inv:get_stack("src",1) + local dstSlot=inv:get_stack("dst",1) if fromList=="src" and count==srcSlot:get_count() then meta:set_float("srcTime",-1) meta:set_float("maxSrcTime",0) if meta:get_float("maxFuelTime")>0 then meta:set_string("formspec",ironFurnaceFormspec(meta:get_float("fuelTime")/meta:get_float("maxFuelTime")*100,0)) end + elseif fromList=="dst" and dstSlot:get_free_space()==0 then + minetest.get_node_timer(pos):start(industrialtest.updateDelay) end end, on_metadata_inventory_put=function(pos,listname,index,stack) @@ -772,12 +786,15 @@ definition={ local meta=minetest.get_meta(pos) local inv=meta:get_inventory() local srcSlot=inv:get_stack("src",1) + local dstSlot=inv:get_stack("dst",1) if listname=="src" and stack:get_count()==srcSlot:get_count() then meta:set_float("srcTime",-1) meta:set_float("maxSrcTime",0) if meta:get_float("maxFuelTime")>0 then meta:set_string("formspec",ironFurnaceFormspec(meta:get_float("fuelTime")/meta:get_float("maxFuelTime")*100,0)) end + elseif listname=="dst" and dstSlot:get_free_space()==0 then + minetest.get_node_timer(pos):start(industrialtest.updateDelay) end end }