From 190f83a60ff7ad34bee3e8f52952a6392e0301f3 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sun, 2 Apr 2023 18:21:39 +0200 Subject: [PATCH] Restart machine if power goes back on --- machines.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/machines.lua b/machines.lua index 9732efe..2aa1ce9 100644 --- a/machines.lua +++ b/machines.lua @@ -955,11 +955,13 @@ local function registerSimpleElectricItemProcessor(config) inv:set_stack("powerStorage",1,powerStorageSlot) end end - if srcSlot:get_count()>0 and meta:get_float("maxSrcTime")<=0 and meta:get_int("industrialtest.powerAmount")>=requiredPower then + if srcSlot:get_count()>0 and meta:get_int("industrialtest.powerAmount")>=requiredPower then local output=craftResultProxy(config.method,srcSlot) if output.time>0 and inv:room_for_item("dst",output.item) then - meta:set_float("srcTime",0) - meta:set_float("maxSrcTime",output.time*config.efficiency) + if meta:get_float("maxSrcTime")<=0 then + meta:set_float("srcTime",0) + meta:set_float("maxSrcTime",output.time*config.efficiency) + end minetest.swap_node(pos,{ name="industrialtest:"..config.name.."_active", param2=minetest.get_node(pos).param2