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 (optional). It's make resource management more like RTS for playing combat-oriented settings/mods. Compatible with multi-surface mods like Space Exploration - item transportation works on surface, but not between them. Should be UPS-friendly because using events to track entities, not find_entities_filtered.

Content
5 months ago
1.1
1.11K
Logistics Logistic network Circuit network Storage

i Display Numbers In Factorio Style

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

I've addes the option to show the item values in shortend string versions like factorio to avoid string clipping on small icon sizes. 10000 -> 10k and on mousover show the exaxt value with a 1000 . tunctation -> 10.125 for example.

https://paste.pics/OW9W2 - Shortend version with tooltip
https://paste.pics/OW9V8 - Settings
https://paste.pics/OW9YE - Without shortend string

Added This to the control.lua:

function short_number(number)
if number == nil then return 0

elseif number <= 999 then return number
elseif number <= 9999 then return string.format("%.1fk", math.floor(number / 100)/10)

elseif number >= 1e12 then return string.format("%.0ft", math.floor(number / 1e12))
elseif number >= 1e9 then return string.format("%.0fg", math.floor(number / 1e9))
elseif number >= 1e6 then return string.format("%.0fm", math.floor(number / 1e6))
elseif number >= 1e3 then return string.format("%.0fk", math.floor(number / 1e3))

end
end

function comma_value(n) -- credit http://richard.warburton.it
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
end

and replaced this on the end of function update_gui(player) in control.lua

local count = frame.add{type="label", caption=data['amount']}
count.style.horizontal_align = 'center'

With:

local itemAmount = data['amount']

local count = frame.add{type="label"}
count.style.horizontal_align = 'center'

if player.mod_settings["QuantumResourceDistribution_raw_value"].value then
count.caption=itemAmount
else
count.caption=short_number(itemAmount)
count.tooltip=comma_value(itemAmount)
end

for the fluid:

local fluidAmount = math.floor(tonumber(data['amount']))

local count = frame.add{type="label"}
count.style.horizontal_align = 'center'

if player.mod_settings["QuantumResourceDistribution_raw_value"].value then
count.caption=fluidAmount
else
count.caption=short_number(fluidAmount)
count.tooltip=comma_value(fluidAmount)
end

and added to the settings.lua

data:extend({
{
type = "bool-setting",
name = "QuantumResourceDistribution_raw_value",
setting_type = "runtime-per-user",
default_value = true,
order = "3"
}
})

greetings

1 year, 4 months ago

Hmm, not bad idea, i think i will add this when i have time, thanks.

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

function comma_value(n) -- credit http://richard.warburton.it
local left,num,right = string.match(n,'^(.-%d)(%d*)(.*)')
return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
end

this is another way to write the function. Had trouble to add the * in the forum.

10 months ago

18-02-24:
- Support for script-raised building events
- Support for big numbers in storage - they will be converted to short notation using "k" and "m" letters
- All items allowed to go to storage by default but you can restrict some groups / subgroups / individual id's

This thread has been locked.