Workarounds for entity prototypes limited to ElectricEnergySource?

Place to post guides, observations, things related to modding that are not mods themselves.
AkBKukU
Burner Inserter
Burner Inserter
Posts: 12
Joined: Fri Sep 08, 2023 2:10 pm
Contact:

Workarounds for entity prototypes limited to ElectricEnergySource?

Post by AkBKukU »

I'm fairly new to modding the game but I got the idea stuck in my head for part of a mod the makes laser turrets that run off heat with the intention of having nuclear reactors closer to the front lines for some risk/reward fun. But from what I've been reading in the API Docs the ElectricTurretPrototype, like many entity prototypes it seems, are limited to the ElectricEnergySource. I created a test mod that attempts to set the energy_source to a heat provider and the game does reject it. I couldn't find a reason why, only that it has been that way since at least 2018: https://wiki.factorio.com/index.php?tit ... did=160245 I would have guessed that the engine is requesting a generic energy drain per each action but it must need something more specific for electricity.

I tried looking up how other people may have solved this and while I'm not the first person to think about using alternate energy sources, it didn't seem like there have been any viable solutions: I'm guessing the hidden entities option has issues when the player mouses over the the visible entity and cannot see what temperature it is effectively at. Are there any other kinds of techniques that could be used for creating something like a heat powered turret that I've missed?
MeteorSwarm
Long Handed Inserter
Long Handed Inserter
Posts: 59
Joined: Thu Sep 25, 2025 10:49 pm
Contact:

Re: Workarounds for entity prototypes limited to ElectricEnergySource?

Post by MeteorSwarm »

For my mod "Muluna, Moon of Nauvis," I added a burner roboport to the game which solved this problem with some relatively inexpensive on_tick scripting and a recipe on_craft event. You will need two entities for this that work together.

1. Roboport entity with electric energy source, but with input flow limit reduced to 0.
2. Assembler entity, consuming liquid fuel for energy, and crafting a recipe that consumes nothing and produces nothing, but set to raise an event when completing the craft.

These entities are connected with the following scripts:

1. On_nth_tick(480): Check the roboport's energy buffer. If energy < 20%, activate the assembler entity so it starts to consume fuel.
2. On_craft: Add n energy to the roboport entity's energy buffer. If energy > 80% deactivate the assembler entity to it stops consuming fuel.

This system consumes fewer resources the larger the entity's buffer is, which is why it naturally works well with roboports. For a turret, you should increase the turret's energy buffer to a value more similar to that used by roboports. On_nth_tick should be frequent enough such that if a turret is fully active, it will not run out of energy before reaching the event.
Post Reply

Return to “Modding discussion”