Hey, this is a cool mod. I've been looking for something with channel isolation for a while and thought about writing one myself, but I don't have much experience with it.
It's very convenient for modularly separating logic blocks.
I decided to expand on it by adding a switch for global and local.
Author: IGRIKRUS <*****>
Date: Sun May 31 00:32:09 2026 +0200
add switch channel global and local
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0dc7b4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.vscode
\ No newline at end of file
diff --git a/control.lua b/control.lua
index 8768438..41965d6 100644
--- a/control.lua
+++ b/control.lua
@@ -19,6 +19,7 @@ local OPEN_INPUT = "circuit-radio-open"
local GUI_NAME = "circuit_radio_gui"
local GUI_SIGNAL = "circuit_radio_signal"
local GUI_VALUE = "circuit_radio_value"
+local GUI_IS_GLOBAL = 'circuit_radio_is_global'
local GUI_SAVE = "circuit_radio_save"
local GUI_CANCEL = "circuit_radio_cancel"
@@ -143,13 +144,19 @@ local function normalize_channel_value(value)
return math.floor(number)
end
-local function make_channel_key(entity, channel_signal, channel_value)
+local function make_channel_key(entity, channel_signal, channel_value, channel_is_global)
local signal = normalize_signal_id(channel_signal)
if not (entity and entity.valid and signal) then
return nil
end
- return "surface:" .. entity.surface.index
+ local surface = "surface_local:" .. entity.surface.index
+
+ if channel_is_global then
+ surface = 'surface_global:'
+ end
+
+ return surface
.. "|force:" .. entity.force.index
.. "|" .. signal_to_text(signal)
.. ":" .. normalize_channel_value(channel_value)
@@ -525,7 +532,7 @@ local function update_channel_render(radio)
return
end
- local channel_key = make_channel_key(radio.entity, radio.channel_signal, radio.channel_value)
+ local channel_key = make_channel_key(radio.entity, radio.channel_signal, radio.channel_value, radio.channel_is_global)
if not channel_key then
radio.entity.custom_status = nil
destroy_channel_render(radio)
@@ -598,7 +605,7 @@ local function refresh_radio_connections(radio)
connect_radio_to_bridge(radio)
update_channel_render(radio)
- local new_key = make_channel_key(radio.entity, radio.channel_signal, radio.channel_value)
+ local new_key = make_channel_key(radio.entity, radio.channel_signal, radio.channel_value, radio.channel_is_global)
if radio.channel_key == new_key then
return
end
@@ -817,6 +824,37 @@ local function open_radio_gui(player, entity)
allow_negative = false
}
+ local mode_flow = frame.add{
+ type = "flow",
+ direction = "horizontal",
+ style = "player_input_horizontal_flow"
+ }
+
+ mode_flow.style.vertical_align = "center"
+
+ mode_flow.add{
+ type = "label",
+ caption = "Local channel"
+ }
+
+ local switch_state = "left"
+ if radio.channel_is_global == true then
+ switch_state = "right"
+ end
+
+ mode_flow.add{
+ type = "switch",
+ name = GUI_IS_GLOBAL,
+ switch_state = switch_state,
+ allow_none_state = false,
+ tooltip = "Choose between Global network (all surfaces) and Local network (this planet only)."
+ }
+
+ mode_flow.add{
+ type = "label",
+ caption = "Global channel"
+ }
+
local button_flow = frame.add{
type = "flow",
name = "circuit_radio_button_flow",
@@ -859,14 +897,22 @@ local function save_radio_gui(player, frame)
local signal_button = find_child_by_name(frame, GUI_SIGNAL)
local value_field = find_child_by_name(frame, GUI_VALUE)
+ local is_global_switch = find_child_by_name(frame, GUI_IS_GLOBAL)
- if not (signal_button and signal_button.valid and value_field and value_field.valid) then
+ if not (signal_button and signal_button.valid and value_field and value_field.valid and is_global_switch and is_global_switch.valid) then
destroy_radio_gui(player)
return
end
radio.channel_signal = normalize_signal_id(signal_button.elem_value)
radio.channel_value = normalize_channel_value(value_field.text)
+
+ if is_global_switch.switch_state == "right" then
+ radio.channel_is_global = true;
+ else
+ radio.channel_is_global = false
+ end
+
refresh_radio_connections(radio)
destroy_radio_gui(player)
I'm also thinking of adding a channel browsing interface to make searching easier, but I have no idea how to do it without on_tick yet. There's a mod similar to what I need called CircuitHUD-V2. It would be nice to add something like that to this mod.
There's also a minor issue. When selecting a copy or delete area, if the cursor is on the combinator, it opens the interface. It would be nice to fix this somehow.
google translate.