Only split power distribution between not fully charged endpoints

This commit is contained in:
mrkubax10 2023-11-17 08:44:21 +01:00
parent 51058a39cb
commit 32669afafe

12
api.lua
View File

@ -229,7 +229,17 @@ industrialtest.api.powerFlow=function(pos)
return false,false return false,false
end end
local powerFlow=meta:get_int("industrialtest.powerFlow") local powerFlow=meta:get_int("industrialtest.powerFlow")
local powerDistribution=math.floor(powerFlow/#network) local endpointCount=0
for _,endpoint in ipairs(network) do
local endpointMeta=minetest.get_meta(endpoint.position)
if not industrialtest.api.isFullyCharged(endpointMeta) then
endpointCount=endpointCount+1
end
end
if endpointCount==0 then
return false,false
end
local powerDistribution=math.floor(powerFlow/endpointCount)
local transferred=false local transferred=false
local roomAvailable=false local roomAvailable=false
for _,endpoint in ipairs(network) do for _,endpoint in ipairs(network) do