@@ -43,6 +43,10 @@ local function render_section(ctx, point_index, section_index)
4343
4444 local menu = Menu .MenuBuilder .new ()
4545
46+ -- Detect if this is a constant combinator to determine signal mode
47+ local is_combinator = entity .type == " constant-combinator"
48+ local signal_mode = is_combinator and " all" or " item"
49+
4650 -- Add rows for each existing filter/request
4751 for i = 1 , section .filters_count do
4852 local slot = section .get_slot (i )
@@ -70,7 +74,7 @@ local function render_section(ctx, point_index, section_index)
7074 on_click = function (ctx )
7175 ctx .controller :open_child_ui (
7276 Router .UI_NAMES .SIGNAL_CHOOSER ,
73- {},
77+ { mode = signal_mode },
7478 { node = row_key .. " _overview" , slot_index = i }
7579 )
7680 end ,
@@ -110,18 +114,26 @@ local function render_section(ctx, point_index, section_index)
110114 end ,
111115 on_child_result = function (ctx , result )
112116 local num = tonumber (result )
113- if num and num >= 0 then
117+ if not num then
118+ UiSounds .play_ui_edge (ctx .pindex )
119+ ctx .controller .message :fragment ({ " fa.logistics-invalid-number" })
120+ elseif not is_combinator and num < 0 then
121+ UiSounds .play_ui_edge (ctx .pindex )
122+ ctx .controller .message :fragment ({ " fa.logistics-value-cannot-be-negative" })
123+ else
114124 local section = provider .get_section (section_index )
115125 if not section then return end
116126
117127 local slot = section .get_slot (i )
118- slot .min = math.floor (num )
119- section .set_slot (i , slot )
128+ if slot .max and num > slot .max then
129+ UiSounds .play_ui_edge (ctx .pindex )
130+ ctx .controller .message :fragment ({ " fa.logistics-min-must-be-at-most-max" , tostring (slot .max ) })
131+ else
132+ slot .min = math.floor (num )
133+ section .set_slot (i , slot )
120134
121- ctx .controller .message :fragment (tostring (math.floor (num )))
122- else
123- UiSounds .play_ui_edge (ctx .pindex )
124- ctx .controller .message :fragment ({ " fa.logistics-invalid-number" })
135+ ctx .controller .message :fragment (tostring (math.floor (num )))
136+ end
125137 end
126138 end ,
127139 on_clear = function (ctx )
@@ -167,18 +179,27 @@ local function render_section(ctx, point_index, section_index)
167179 ctx .controller .message :fragment ({ " fa.infinity" })
168180 else
169181 local num = tonumber (result )
170- if num and num >= 0 then
182+ if not num then
183+ UiSounds .play_ui_edge (ctx .pindex )
184+ ctx .controller .message :fragment ({ " fa.logistics-invalid-number" })
185+ elseif num < 0 then
186+ UiSounds .play_ui_edge (ctx .pindex )
187+ ctx .controller .message :fragment ({ " fa.logistics-value-cannot-be-negative" })
188+ else
171189 local section = provider .get_section (section_index )
172190 if not section then return end
173191
174192 local slot = section .get_slot (i )
175- slot .max = math.floor (num )
176- section .set_slot (i , slot )
177-
178- ctx .controller .message :fragment (tostring (math.floor (num )))
179- else
180- UiSounds .play_ui_edge (ctx .pindex )
181- ctx .controller .message :fragment ({ " fa.logistics-invalid-number" })
193+ local min_val = slot .min or 0
194+ if num < min_val then
195+ UiSounds .play_ui_edge (ctx .pindex )
196+ ctx .controller .message :fragment ({ " fa.logistics-max-must-be-at-least-min" , tostring (min_val ) })
197+ else
198+ slot .max = math.floor (num )
199+ section .set_slot (i , slot )
200+
201+ ctx .controller .message :fragment (tostring (math.floor (num )))
202+ end
182203 end
183204 end
184205 end ,
@@ -220,7 +241,7 @@ local function render_section(ctx, point_index, section_index)
220241 ctx .message :fragment ({ " fa.logistics-add-request" })
221242 end ,
222243 on_click = function (ctx )
223- ctx .controller :open_child_ui (Router .UI_NAMES .SIGNAL_CHOOSER , {}, { node = " add_filter" })
244+ ctx .controller :open_child_ui (Router .UI_NAMES .SIGNAL_CHOOSER , { mode = signal_mode }, { node = " add_filter" })
224245 end ,
225246 on_child_result = function (ctx , result )
226247 if result then
0 commit comments