Circuit-controlled dynamic radar channels

by Sixic

Adds circuit-controlled dynamic universe-channel selection to radars.

Utilities
a month ago
2.1
13
Circuit network
Owner:
Sixic
Source:
N/A
Homepage:
N/A
License:
MIT
Created:
a month ago
Latest Version:
0.1.1 (a month ago)
Factorio version:
2.1
Downloaded by:
13 users

Circuit-controlled dynamic radar channels

This mod allows radars to switch their universe channel automatically based on circuit-network signals.
Each radar can be assigned a control channel. When dynamic channel selection for a radar is enabled, the radar listens for signals provided by another radar on that control channel. The signal received on that control channel is then used as the radar's current universe channel.
If the source radar provides no signal, the dynamic radar also disconnects from its universe channel.

Usage

Set up one radar as the control signal source and configure its universe channel to the channel you want to use as a control channel.
Then configure another radar using this universe channel as its control channel and check the "Enable dynamic channel selection" box.
Signals sent to the first radar are then used by the second radar as its universe channel.
The signal used for the control channel should not itself be present as a signal on the control channel. Select a dedicated control channel that does not conflict with any other universe channels used in your circuit network.

The example below shows the intended setup: one radar acts as the control-signal source, while another radar uses that signal to dynamically select its universe channel.

Update interval

By default, the mod updates dynamic channels every tick to enable tick-accurate switching.
If you do not require such a high switching rate, you can increase the update interval in the mod settings.
This reduces the frequency at which the mod checks and applies signal changes and can reduce CPU usage when operating a large number of dynamic radars.

Important limitations and notes

Circuit network ID exhaustion

Changing a radar's universe channel causes Factorio to reconnect the affected circuit-network segment. This process can increment the circuit network ID.
The network ID is ultimately limited to 2^32 - 1. At a maximum update rate of 60 changes per second, reaching this limit with a single dynamic radar would require approximately 19,884 hours of continuous channel switching.
This is a theoretical worst-case scenario, but using multiple dynamic radars at the maximum update frequency can reach the limit sooner overall.
For systems that switch channels continuously, especially when using many dynamic radars, consider increasing the signal switching interval instead of switching at the maximum frequency. Here, "switching interval" refers to how frequently the signal sent to the control channel is changed.
If the limit is reached, an overflow occurs, resulting in duplicate circuit network IDs. The circuit network ID is primarily a value used for debugging and is not used by Factorio to determine whether circuit networks are physically connected. Even if two networks share the same circuit network ID, they remain separate and continue to function normally.
However, other mods that process circuit network IDs and assume they are always unique may encounter errors when duplicate IDs occur, so such mods may be affected.
This is not a limitation of the Dynamic Radar Channels mod itself, but rather a behavior of the game engine. The same thing would happen if you were to change the channel manually at a high rate.

Missing control-channel source

A dynamic radar with an enabled but currently unavailable control channel will continuously search for a radar that provides that channel, thereby increasing CPU usage until one is found. This also applies if the dynamic radar itself is not physically connected to a circuit network.
Therefore, ensure that for every radar with dynamic channel selection enabled, there is at least one radar available that provides the required channel.
The mod periodically issues an error message to alert you should this situation occur unintentionally. This makes unintended missing-source configurations easier to detect.

Compatibility

This mod works by controlling the existing radar universe channel. It does not add new radar entities or replace the vanilla radar GUI. It only adds a small additional GUI panel.
Compatibility with other mods has not been tested. Other mods that rely on circuit network IDs being unique may be affected if duplicate IDs occur due to an ID overflow.

Development transparency

This mod was developed with both human and AI assistance.

Human contributions

  • Mod concept and feature requirements
  • Gameplay behavior and design decisions
  • UI and UX design
  • Testing and identification of edge cases
  • Minor bug fixes
  • Final review
  • Screenshots

AI-assisted contributions

  • Lua implementation assistance
  • Log file and code analysis
  • Localization
  • Documentation drafting
  • Thumbnail