OCs base assets

by OC1024

Helper Mod for my mods without playable content on its own.

Internal
2 days ago
2.0
2.84K
Factorio: Space Age Icon Space Age Mod
Owner:
OC1024
Source:
N/A
Homepage:
N/A
License:
GNU GPLv3
Created:
1 year, 15 days ago
Latest Version:
0.4.2 (2 days ago)
Factorio version:
2.0
Downloaded by:
2.84K users

Overview

This is my graphics and utility library mod. It does nothing on its own except preparing the recipe generator before use. Most of my mods use that generator and all other mods depend on this.


Technical details

For other modder and interested ones.
If you want to have an mod compatibility example, I have one in my main mod.

Energy Calculation Example

This mod's recipe_generator calculates the total crafting time of a recipe by recursively expanding all intermediate products.
Each recursive step contributes less to the total energy, controlled by a reduction factor.

The general idea:

  • The base recipe energy is always fully counted
  • Each recursive step is multiplied by a constant factor (f)
  • Deeper crafting chains therefore contribute less

Formally:

E_{total} = E_{base} + \sum_i E_i \* f^{d_i}

Where:

  • E_{base}: crafting time of the selected recipe
  • E_i: crafting time of a sub-recipe
  • d_i: recursion depth
  • f: energy reduction factor (between 0% and 100%, a mod setting, default 80%)

Example: Piercing Rounds Magazine

The recipe chain (simplified) looks like this:

  • Piercing Rounds Magazine
  • Copper Plate
  • Steel Plate
  • Firearm Magazine
  • Iron Plate

This creates two levels of recursion.


Step 1: Base Recipe

Piercing Rounds Magazine:

  • Crafting time: <E_base> = 6s

Step 2: First Recursion Layer

Ingredients expanded:
- 1 Steel Plate → <E_steel> = 3.2s
- 2 Copper Plate → <E_cu> = 3.2s
- 2 Firearm Magazine → 2 <E_firearm> = 2s

These are the crafting times from the foundry recipes of steel and copper plate. These two ingredients are fully resolved.
Most are base materials. But the Firearm Magazine has to be dissected further, see next step.
For each part the reduction factor (f) is applied:
- 1 E_{steel} \* f
- 1 E_{cu} \* f
- 2 E_{firearm} \* f

Here, the prefactor gives the amount of how many times this recipe is needed.

Step 3: Second Recursion Layer

Firearm Magazine expands further:

  • 8 Iron Plate → 4 <E_{iron}> = 4 * 3.2s = 12.8s

Note, we need 2 firearm magazine, therefore 8 iron plates. Per craft, we get 2 iron plates in 3.2s from the Foundry.
Again, the reduction factor is applied. Since this is the second time for the iron plates from the fire arm magazine, effectively it is squared:

  • E_{iron} \* f^2

Final Result

E_{total} =
=<E_{base}> + f \* ( <E_{steel}> + <E_{cu}> + <E_{firearm}> ) =
= 6s + 0.8 * ( 3.2s + 3.2s + 2 * ( 1 + 0.8 * 2 * 3.2) =
= 6s + ( 2.56s + 2.56s + 0.8 * 2 * 6.12s) =
` = 20.88s´

The result is rounded to one decimal place and saved.
This is how we get a crafting time of 20.8s for the "casting piercing firearm magazine" recipe on default setting.
Note: the firearm magazine is also calculated with 6.1s and used therefore with the rounded value in the actual mod.


Special Cases

  • (f = 1)
    Full recursive expansion (no reduction). Recipe crafting time will be very long.

  • (0 < f < 1)
    This is the usual behaviour; deeper recipes matter less and less.

  • (f = 0)
    Only the base recipe counts:
    E_{total} = E_{base}
    This allows you to completely ignore intermediate crafting complexity if desired.

My other mods:

OCs Ammo and Armor -> for easy ammo production
OCs Stone Casting -> for all stone-related things
OCs Exoplanetary Expansion -> the "modpack"
OCs Alternative Science Production -> alternative science recipes
OCs Nauvis Science Port -> enables base game sciences in non-Nauvis buildings