SuperFactoryManager icon indicating copy to clipboard operation
SuperFactoryManager copied to clipboard

[Feature Request]: Evenly distribute

Open tnthung opened this issue 10 months ago • 0 comments

Description

Version: 4.19.0

In my current version, the super factory manager cannot do the even distribution.

For example, I have a chest which prepared a batch of ingredients for 10 machines to work simultaneously. My current setup will be trying to use some mechanic to split each type of ingredient into their own chest, and do

-- I for input
-- M for machine
-- O for output

every 20 ticks di
    input from I1
    output 1 to each M
    forget

    input from I2
    output 1 to each M
    forget

    -- more chests...

    input from M
    output to O
end

This has many drawback:

  1. It's very verbose, if a recipe requires more than 5 types of ingredient, the screen just won't fit the code without scrolling.

  2. It's either too slow, or you have to over produce.

    • Too slow: If you only output 1, for recipes requiring maybe 10 items per production, it would take 10 secs to just get the ingredients in, and 1 extra sec to get to product out.

    • Over produce: Say you want to speed things up, so you want to do output 5. Which means every recipe this prod-line must fulfill the multiple of 5.

      For example: 1. A recipe is 2A + 3B = 1C. In order for 1 machine to fully consume the ingredients without remaining, you need to find the LCM of (2, 5) and (3, 5) that still preserve the ratio, which will be (10, 15). And you'll produce 5 product per machine. But sometimes the ingredient can be costly, you can't just shove in everything you have in order to make 1 and end up getting 5.

  3. Recipe with fluids virtually can't work, many mod would require the various recipe to consume different amount of fluid. Some maybe only need 10mb while other require 1B, in this case, using the point 2 method will make the crafting horrendously slow for recipes requiring more fluid.

My proposal

Add 4 new subcommands:

[RELAXED | STRICT] EVENLY [BY AMOUNT | BY TYPE]

  • RELAXED means evenly distributing the part that is divisible, and the rest evenly goes to first few outputs. More
  • STRICT means only output the part where it's fully divisible by the number of outputs.
  • BY AMOUNT means counting all inputs as a whole.
  • BY TYPE means each input type is treated individually.

Examples

I have 21 coals + 15 irons, and O is 5 chests.

every 20 ticks do
    input from I
    output to O relaxed evenly by amount
end

-- O1 have 7 coals + 1 irons
-- O2 have 7 coals
-- O3 have 7 coals
-- O4 have 7 irons
-- O5 have 7 irons
every 20 ticks do
    input from I
    output to O strict evenly by amount
end

-- O1 have 7 coals
-- O2 have 7 coals
-- O3 have 7 coals
-- O4 have 7 irons
-- O5 have 7 irons
every 20 ticks do
    input from I
    output to O relaxed evenly by type
end

-- O1 have 5 coals + 3 irons
-- O2 have 4 coals + 3 irons
-- O3 have 4 coals + 3 irons
-- O4 have 4 coals + 3 irons
-- O5 have 4 coals + 3 irons
every 20 ticks do
    input from I
    output to O strict evenly by type
end

-- O1 have 4 coals + 3 irons
-- O2 have 4 coals + 3 irons
-- O3 have 4 coals + 3 irons
-- O4 have 4 coals + 3 irons
-- O5 have 4 coals + 3 irons

More on RELAXED

As previously stated, the rest of ingredients goes to the first few outputs. The first few is important, it implies the order should always be preserved. This ensures the ingredients aligned the recipe. For example:

-- I: 6 coals + 6 irons
-- M: 5 machines
-- O: a chest

every 20 ticks do
    input coal from I
    output to M relaxed evenly by type north side
    forget

    input iron from I
    output to M relaxed evenly by type south side
    forget
    
    input from M bottom side
    output to O
end

If the order is not fixed, in this example RELAXED will be essentially useless. Because a situation might happen where M1 got remaining coals but M3 got remaining raw irons and breaking the factory. To prevent this, the order when distributing should always be fixed before the labels are pushed again.

tnthung avatar Feb 21 '25 22:02 tnthung