Last active
June 4, 2019 20:32
-
-
Save alercah/f285ca050b8857768e0b30188e3edd51 to your computer and use it in GitHub Desktop.
Ratio calculation interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculate(recipes, constraints): | |
Calculates the optimal ratios for the specified recipes. | |
Params: | |
recipes: Table of string -> recipe. Recipe data and parameters. Note that you may have to use keys encoding additional parameters where multiple of the same recipe are used, say with different machines. | |
constraints: | |
Returns: Table with keys: | |
item, fluid: Table of string -> double. Amount of item/fluid produced (negative is consumption) per unit time. | |
recipe: Table of string -> double. Number of each recipe required. | |
power: double. The total power produced (negative is consumed) by this recipe (in W). | |
type recipe, table with keys: | |
item, fluid: Table of string -> double. Amount of item/fluid produced (negative is consumption) per instance of the recipe. | |
time: | |
double. number of ticks to create the item (equal to ceil(energy * crafting speed * 60)). | |
power: | |
double. power produced (negative is consumed) by this recipe (in W). | |
type constraints, table with keys: | |
unit: | |
double. number of ticks to count in one unit time (e.g. 60 for per-second calculations). Default to 60. | |
min: | |
table with keys: | |
item, fluid: | |
table of string -> double. Minimum production of the item per unit time (negative is consumption). Default has no minimum. | |
recipe: | |
table of string -> double. Minimum number of a specified recipe (i.e. assemblers or subfactories) to use. | |
power: double. Minimum amount of power (negative is consumption) to produce (in W). | |
max: as min, but maxima instead of minima | |
priority: | |
array of array of table with keys: | |
item, fluid: | |
table of string -> double. The priority of reducing the amount of excess input/output of this item/fluid. Higher means it will be prioritized first. Only the ordering matters, not the scale (e.g. priorities 10/2/1 are the same as 2/1.5/1) Default is 0. | |
recipe: | |
table of string -> double. The priority of limiting the number of instances of this recipe. Higher means it will be prioritized first. Default is 0. | |
power: double. The priority of limiting power consumption. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment