Merge Signals Combinator

by Hermios

New combinator that multiply signals coming from green wire to signals coming from red wire

6 months ago
1.1
214

b Index out of bounds when switching surface (Space Exploration)

6 months ago

Hey.. New bug found :)

Using Up to date factorio 1.1.107 and mod v1.0.4 with space exploration 0.6.130

When switching surface using universe explorer (Nauvis Orbit to Nauvis), I get the exception below. It's not the first time I change surface with merge combinators built, so for now I see it as a random occurrence

The mod Merge Signals Combinator (1.0.4) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event Merge_Signals_Combinator::on_tick (ID 0)
Index out of bounds: 71 >= 20.
stack traceback:
[C]: in function 'set_signal'
...nals_Combinator__/prototypes/merge-signal-combinator.lua:26: in function 'update_output'
Merge_Signals_Combinator/control.lua:10: in function 'f'
Hermios_Framework/control-libs.lua:20: in function <Hermios_Framework/control-libs.lua:13>

6 months ago

Update: the issue triggered not when changing surfaces but when adding many (probably 71) signals at once (by plugging in a roboport as "read network contents") to a big network with several merge signal combinators used as filters

6 months ago

I wrote myself a quick fix, seems to be working with smoke tests and my current save. See the diff below, I didn't manage to create a github account for sending a real pull request

--- XXX\mods\Merge_Signals_Combinator_1.0.4\prototypes\merge-signal-combinator.lua.bak
+++ XXX\mods\Merge_Signals_Combinator_1.0.4\prototypes\merge-signal-combinator.lua
@@ -20,10 +20,13 @@
if not red_data or not green_data then
return
end
+
+ local output_signal_index = 1
for i,signal_data in pairs(red_data.signals or {}) do
signal_data.count=green_data.get_signal(signal_data.signal)*signal_data.count
if signal_data.count~=0 then
- self.sender.get_or_create_control_behavior().set_signal(i,signal_data)
+ self.sender.get_or_create_control_behavior().set_signal(output_signal_index,signal_data)
+ output_signal_index = output_signal_index + 1
end
end
end

function msc_prototype:on_removed()
self.sender.destroy()
end
\ No newline at end of file

6 months ago

Hei hei, it's not a bug, it's a feature... :D
I fixed it, but i'll limit the number of signals to 20max. Every signal above this one will be ignored. Please test! Thanks a lot for the feedback!

6 months ago

:)

Why limit the number of signals? UPS?
Would better leave that as a startup setting

6 months ago

Nope, limitation of the system itself. To generate the new signals, I use a constant combinator, which doesn't allow more than 20 signals. So it is not on me!

6 months ago

Right!
As long as input signals stay unlimited, I'm happy to keep using them as filters

6 months ago

Hei, I actually got an idea to change it, and make it work without limit, and even without UPS issues. But I have to validate it first!

New response