Update formspec after item is taken when it's actually needed

This commit is contained in:
mrkubax10 2025-03-11 18:55:11 +01:00
parent 70dacf9a8c
commit c379b133dc

View File

@ -98,12 +98,10 @@ function industrialtest.SimpleElectricItemProcessor.onMetadataInventoryMove(self
local inv=meta:get_inventory() local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1) local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1) local dstSlot=inv:get_stack("dst",1)
if fromList=="src" and count==srcSlot:get_count() then if fromList=="src" and srcSlot:is_empty() then
meta:set_float("srcTime",-1) meta:set_float("srcTime",-1)
meta:set_float("maxSrcTime",0) meta:set_float("maxSrcTime",0)
if meta:get_int("industrialtest.powerAmount")>0 then
self:updateFormspec(pos) self:updateFormspec(pos)
end
elseif fromList=="dst" and dstSlot:get_free_space()>0 then elseif fromList=="dst" and dstSlot:get_free_space()>0 then
self:triggerIfNeeded(pos) self:triggerIfNeeded(pos)
end end
@ -120,12 +118,10 @@ function industrialtest.SimpleElectricItemProcessor.onMetadataInventoryTake(self
local inv=meta:get_inventory() local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1) local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1) local dstSlot=inv:get_stack("dst",1)
if listname=="src" and stack:get_count()==srcSlot:get_count() then if listname=="src" and srcSlot:is_empty() then
meta:set_float("srcTime",-1) meta:set_float("srcTime",-1)
meta:set_float("maxSrcTime",0) meta:set_float("maxSrcTime",0)
if meta:get_int("industrialtest.powerAmount")>0 then
self:updateFormspec(pos) self:updateFormspec(pos)
end
elseif listname=="dst" and dstSlot:get_free_space()>0 then elseif listname=="dst" and dstSlot:get_free_space()>0 then
self:triggerIfNeeded(pos) self:triggerIfNeeded(pos)
end end