Machine Upgrades


This mod provides an API to make technologies that upgrade crafting machines (at runtime). Example: Researching X => Assemblers +10% Speed, or Chemical Plants +20% Productivity. This mod does nothing by itself, and is intended to be used with other mods.

Internal
14 days ago
2.0
6.53K
Manufacturing
Owner:
LoupAndSnoop
Source:
https://github.com/LoupAndSnoop/machi...
Homepage:
https://discord.gg/CaDJzEj557
License:
GNU GPLv3
Created:
a month ago
Latest Version:
0.69.12 (14 days ago)
Factorio version:
2.0
Downloaded by:
6.53K users


Reach me fastest on Discord.


This mod allows you to make technologies upgrade a machine like with module effects. It works by secretly making invisible beacons on every single entity of a given type automatically.

Look at test-suite.lua to see actual working usage.

How to Use

For convenience, data can be passed in using a type called MUpgradeData. Input something like this in data stage:

local my_upgrade_data = {
    {
        handler = "Assembler-speed-boosting",
        technology_name = "steel-processing",
        modifier_icon = {icon="__base__/graphics/icons/electric-furnace.png"},
        entity_names = {"electric-furnace", "oil-refinery"},
        module_effects = {speed = 0.3, pollution = -0.1},
        effect_name = nil, --would make an effect that says "Electric Furnace: -10% Productivity
    },
    {
        handler = "Actually_uses_assemblers",
        technology_name = "steam-power",
        modifier_icon = {icon="__base__/graphics/icons/chemical-plant.png"},
        entity_names = {"assembling-machine-2"},
        module_effects = {productivity = -0.1, consumption = -0.1, quality = 0.2},
        effect_name = "My custom string", --would make an effect that says "My custom string: -10% Productivity
    }
}

local mupgrades = require("__machine-upgrades__.lib.technology-maker")
mupgrades.handle_modifier_data(my_upgrade_data)

Manual usage

Not recommended. If you want full manual control, the most important functions in this mod are:
- mupgrade_lib.make_modifier : Use this in data stage to create the desired effect in a technology.
- mupgrade_lib.add_id_flag : Use this to safely add the get-by-unit-number flag to an entity.
- remote.call("machine-upgrades-techlink", "add_technology_effect", technology_name, entity_name, effect, entity_handler): Use this in control stage in an event callback to tie a specific entity prototype and effect to the technology's research progress.


Note that entity_handler should be matched to the same entity_name(s) to save on UPS.

Thanks: plexpt for the Big Data String 2 mod, used in packing data for more convenience.