factoriolab / factoriolab

Angular-based calculator for factory games like Factorio and Dyson Sphere Program
https://factoriolab.github.io
MIT License
445 stars 103 forks source link

Individual module preferences for factories #388

Open dcbroad3 opened 3 years ago

dcbroad3 commented 3 years ago

Currently, factory settings allow picking preferences for all slots at once. It may be helpful to have the ability to set individual module slot preferences separately, for example to set to prod/speed for modules 1 & 2, and efficiency for modules 3 & 4.

Requested by Fireball770 in Discord

To have to be able to set modules automatically, ik u can do all speed or all prod, but to have like 2 prod 1 speed in machines that can have prod, and then the others be speed

dcbroad3 commented 8 months ago

Potential design:

Swap array of modules for a tuple of string or array of strings:

type ModulePreference = string | string[];
type ModulePreferences = [ModulePreference, ModulePreference | undefined];
export interface Settings {
  moduleRank: ModulePreferences;
}

A string module preference would represent 'fill with this module', where a string array represents 'use these modules in each slot'. Module preferences are a tuple where the first item is the preferred configuration, and the second item (optional) is a fallback that is always used if productivity is not allowed for the recipe. (Under the hood, this would probably always be used if any limitation is declared, not just productivity) In this fallback, only modules that do not have a limitation would be allowed.

This should likely be a dialog when editing modules in factory preferences, with two rows, the latter being optional representing the fallback.