Page 1 of 1

[2.0.72] can_satisfy_request ignore count

Posted: Wed Jan 07, 2026 5:34 pm
by Stargateur
https://lua-api.factorio.com/latest/cla ... fy_request look like to ignore count. the following code:

Code: Select all

local n = aqu.get_used_item_by_network(network, module.name, quality.name) + 1
if network.can_satisfy_request({ name = module.name, quality = quality }, n, true) then
if n > 100 then
  log(n)
  log(module.name .. quality.name)
end
106.193 Script @__AutoQualityUpgrades__/control.lua:207: 101
106.193 Script @__AutoQualityUpgrades__/control.lua:208: productivity-module-3uncommon
106.194 Script @__AutoQualityUpgrades__/control.lua:207: 102
106.194 Script @__AutoQualityUpgrades__/control.lua:208: productivity-module-3uncommon
106.194 Script @__AutoQualityUpgrades__/control.lua:207: 103
106.194 Script @__AutoQualityUpgrades__/control.lua:208: productivity-module-3uncommon
106.194 Script @__AutoQualityUpgrades__/control.lua:207: 104
for only one module available with this quality n would be far superior to 100 and can_satisfy_request still return true somehow

Edit: replaced with `if network.get_item_count({ name = module.name, quality = quality }) > n then` work as expect, I will see if I can give a MRE later I need to go.

Re: can_satisfy_request ignore count

Posted: Wed Jan 07, 2026 5:44 pm
by Rseding91
Thanks for the report however I am unable to reproduce any such issue when I test and you haven't provided any save file or test mod to show what issue you're running into.

Re: [2.0.72] can_satisfy_request ignore count

Posted: Thu Jan 08, 2026 12:10 am
by Stargateur
I have trouble to produce a MRE, it's look like it's happen when item count return negative number.

Code: Select all

 106.679 Script @__AutoQualityUpgrades__/control.lua:208: item_count = -6
 106.679 Script @__AutoQualityUpgrades__/control.lua:209: n = 101
 106.679 Script @__AutoQualityUpgrades__/control.lua:210: productivity-module-3
 106.679 Script @__AutoQualityUpgrades__/control.lua:211: "[LuaQualityPrototype: uncommon (quality)]"

Code: Select all

local n = aqu.get_used_item_by_network(network, module.name, quality.name) + 1
if network.can_satisfy_request({ name = module.name, quality = quality }, n, true) then
  if n > 100 then
    log("item_count = " .. network.get_item_count({ name = module.name, quality = quality }))
    log("n = " .. n)
    log(module.name)
    log(serpent.block(quality))
  end
Or I don't understand `can_satisfy_request` I ask can you satisfy 101 item of this quality it's answer true even when item count say network have -6

Re: can_satisfy_request ignore count

Posted: Thu Jan 08, 2026 8:07 pm
by Stargateur
Rseding91 wrote: Wed Jan 07, 2026 5:44 pm Thanks for the report however I am unable to reproduce any such issue when I test and you haven't provided any save file or test mod to show what issue you're running into.
Do you need more info ? I will use get_item_count for now, even if I guess it's cost more UPS cause it will count every item in the network.

Re: [2.0.72] can_satisfy_request ignore count

Posted: Thu Jan 08, 2026 8:25 pm
by Rseding91
Ah that would do it. I'll fix it for 2.1.