Quantum Resource Distribution

by eliont

Special chest can send placed items to ship quantum storage unit and retrieve from it. Also works for player inventory. It's make resource management more like RTS for playing combat-oriented settings/mods like Warp Drive Machine. Item transportation works across each surface, but not between them. UPS-friendly. Works with factorissimo-2-notnotmelon_3.x.x.

Content
5 days ago
1.1 - 2.0
357
Logistics Logistic network Circuit network Storage

g Fulfill partial requests

1 year, 11 months ago

Hi, I am using the mod in my new SE K2 playthrough and have noticed that the storage appears to only provide items if it can satisfy the whole request. ie I have 9 iron gears in storage and am requesting 10, it won't provide any iron gears to the chest. Is there a way to change this behavior? ie let it provide the 9 gears while production catches up

1 year, 11 months ago
(updated 1 year, 11 months ago)

So after digging through a LUA guide and checking the factorio modding guide, I was able to modify the "take" and "put" functions to do what I was looking for. I will paste the modifications here if anyone is interested. This in in the control.lua file.

function take(surface,inv,item,amount)
if not global.pool[surface.name] then global.pool[surface.name] = {} end
if not global.pool[surface.name][item] then global.pool[surface.name][item] = 0 end
if global.restricted[item] == true then return end

local maxstore = 99999

if global.pool[surface.name][item] + amount > maxstore then amount = maxstore - global.pool[surface.name][item] end
if amount <= 0 then return end
global.pool[surface.name][item] = global.pool[surface.name][item] + amount
inv.remove({name=item, count=amount})
end

function put(surface,inv,item,amount)
if not global.pool[surface.name][item] then return end -- ignore if item isn't in pool
if inv.get_insertable_count(item) < amount then amount = inv.get_insertable_count(item) end

local content = inv.get_contents()
local needed = amount

if content[item] then needed = needed - content[item] end
if needed <= 0 then return end
if global.pool[surface.name][item] < needed then needed = global.pool[surface.name][item] end
if needed <= 0 then return end

global.pool[surface.name][item] = global.pool[surface.name][item] - needed
inv.insert({name=item, count=needed})
end