Building Regeneration
A small personal-use mod for Factorio 2.1.24, with base-game and Space Age support.
Normal buildings belonging to player forces recover 1 HP each second by default, including during combat. The one startup setting, Building health recovery (HP/s), accepts an absolute nonnegative rate. Set it to 0 to disable. Fractional values are supported. Apply startup-setting changes and restart/reload when prompted.
Install
Copy building-regeneration_0.1.0.zip into the Factorio user-data mods directory, enable Building Regeneration, and restart when prompted. The default macOS directory is ~/Library/Application Support/factorio/mods. The source folder can also be installed as building-regeneration_0.1.0 without the development tests.
Scope
The selector admits normal player-placeable stationary buildings from an explicit type allowlist, plus native rail segments and the space-platform hub. This includes production, mining, agriculture, logistics, fluid systems, power, research, signals, rail infrastructure, walls, gates, land mines, all turret families and Space Age platform/industrial facilities. Hidden/debug entities and auxiliary rail supports are excluded.
The tested official data yields 82 building prototypes in base and 113 with Space Age. Rail segments are included even when they are generated indirectly from a rail item; surviving legacy rail segments are supported. Platform hubs are included despite not being directly placed by their own building item.
Characters, cars, tanks, Spidertron, locomotives, rolling stock, construction/logistic/combat/capture robots, enemies, nests, rocks, trees, ruins, ghosts and item stacks are not recovery targets. The captured biter spawner is also excluded, in keeping with the exclusion of nests.
Eligible forces are the standard player force and custom forces with assigned players, including offline players. Built-in enemy and neutral forces and custom forces without players are excluded. Player factions remain eligible even if hostile to another player faction. Ownership is checked again before each recovery payment, so transferring a tracked building to the enemy stops its recovery.
Why a small runtime script is necessary
EntityWithHealthPrototype.healing_per_tick applies to every instance of a prototype, regardless of force. It cannot give a player pipe regeneration while excluding an identical enemy-owned pipe. To meet the force restriction exactly, this mod leaves all prototypes unchanged and uses minimal event-driven recovery instead.
Only damaged eligible buildings are remembered. Every 60 game ticks, their force and validity are checked and their health is increased, capped at the entity's actual maximum health. Full-health, destroyed and no-longer-eligible entries are removed. Quality does not multiply the absolute recovery rate. The first payment occurs on the next normal one-second schedule, with no out-of-combat delay.
Existing damaged buildings are discovered once when installing or reconfiguring the mod. Normal damage and building/clone/revive events keep the damaged set current; player-force changes, force merges and imported surfaces trigger relevant discovery. There is no repeated full-map scan, and setting the rate to 0 unregisters damage/build/recovery handlers.
Console commands or unrelated mods that silently change an untracked entity's health or force without the corresponding events are outside the normal-gameplay scope; initialization/reconfiguration will rediscover eligible existing damage. Large-factory performance has not been benchmarked; periodic work scales with the damaged set, not all healthy buildings.
Behavior preserved
- No changes to maximum health, resistances, original healing prototypes, damage or other combat attributes.
- No energy, fuel, repair packs or items are consumed by this mod.
- No rebuilding, resurrection, ghost revival or inventory-item repair.
- Existing native regeneration on excluded entities is left alone; enemies are not given additional healing by this mod.
- No new buildings, recipes, technologies, UI or dependencies beyond the base game.
Validation
Verified with the installed Factorio 2.1.24, mac-arm64 in isolated configurations. Player saves and installed mods are not touched.
python3 tests/run.py
python3 tests/existing.py
The first runner accepts --keep /new/test/directory; both accept --factorio and --data for another installation. Python's standard library is sufficient. No build command is used.
Checks cover exact prototype equality with vanilla, one registered startup setting, base and Space Age loading, rates 0 / 0.25 / 1 / 10 HP/s, representative building families, normal/legendary equal absolute recovery, healing under repeated damage, maximum-health cap, custom player forces, same-prototype enemy/neutral/unowned forces, ownership transfer, all exclusion classes, damaged-item placement, no inventory-item repair and no recreation of destroyed entities. A separate save test enables the mod on an already-damaged vanilla building and confirms discovery and force isolation.
The tests inspect the complete selected-name set but do not individually place every selected prototype. Multiplayer client synchronization, every elevated-rail/platform placement sequence, and large-map performance are not separately tested.
Official references: health prototypes, entity health, and player-force membership.