[Twinsen] [0.17.45] Combinators allow lua to set their signals to logic signals when they shouldn't

This subforum contains all the issues which we already resolved.
Post Reply
Allaizn
Former Staff
Former Staff
Posts: 90
Joined: Sat Mar 03, 2018 12:07 pm
Contact:

[Twinsen] [0.17.45] Combinators allow lua to set their signals to logic signals when they shouldn't

Post by Allaizn »

There are three special virtual signals (the wiki calls them logic singnals) that should to my knowledge only be seen in the settings of things connected to the circuit network: "signal-everything", "signal-anything" and "signal-each".
Place down a constant combinator anywhere, and run the following command to see the problem in action:

Code: Select all

/c local behavior = game.player.selected.get_control_behavior()
behavior.set_signal(1, {signal={name="signal-everything",type="virtual"}, count=1})
behavior.set_signal(2, {signal={name="signal-anything",  type="virtual"}, count=1})
behavior.set_signal(3, {signal={name="signal-each",      type="virtual"}, count=1})
The result should be this:
Image
This surprisingly doesn't result in any weird behavior - the signals are simply treated like any others, and don't mess with any conditions.
The GUI is also slightly broken, since it only updates the preview of the constant combinator, but not the signals itself after the command is run. Only after closing and reopening it again, the set signals appear and until then, it looks like this:
Image

Decider combinators have a similar lack of guard against these signals: they seem to do a consistency check for the left input & the output signal, but the second signal doesn't. Place a decider combinator and run the following command:

Code: Select all

/c game.player.selected.get_control_behavior().parameters =  {parameters={second_signal = {type="virtual",name="signal-anything"}} }
First off: please fix this command! Something went wrong. According to the lua-api, there shouldn't be the need for the second parameters there!
Secondly, here is the result of that command:
Image
I tried a few things, and it seems to simply interpret it like any other signal, but it's at best very misleading to allow this state to exist.
The GUI doesn't update here properly either :(

Lastly, the same command also works on arithmetic combinators, and (when setting each) allows us to at least try to achieve some sought after states ;)
Image
I was hopeful for 0.3s that this would actually do a parallel multiply, but it instead treats the right each like a normal signal, i.e. feeding in [Each = 2, A=3] results in [Each = 4, A = 6] and feeding in [A = 1, B=-2] results in no output (since everything got multiplied by 0)

So to summarize, there are three kind of related bugs here (sorry that I didn't post them separately!):
1. Combinators don't guard against logic signals when set via lua
2. LuaDeciderCombinatorControlBehavior and LuaArithmeticCombinatorControlBehavior have parameters.parameters as subfield, not just parameter
3. Combinators don't update their GUI immediately when modified by lua

tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Re: [0.17.45] Combinators allow lua to set their signals to logic signals when they shouldn't

Post by tehfreek »

This sounds like a long fix. Each circuit device would have to carry information about every virtual-signal-special as to where it would be valid, then the Lua code and GUI could query each device for the information and allow/show the signals as appropriate.

Twinsen
Factorio Staff
Factorio Staff
Posts: 1329
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [0.17.45] Combinators allow lua to set their signals to logic signals when they shouldn't

Post by Twinsen »

I fixed point 1 in Version: 0.17.46.
Make sure your game doesn't have any combinators in an invalid state or it will now error on load.

Point 2. I'm not sure why it's this way, but it's probably because it allows setting the parameters as a whole. I don't think it's worth the time and the broken mods to change it.

Point 3. It's a common known issue with most lua apis and with multiplayer. We still consider it's not worth fixing.

Allaizn
Former Staff
Former Staff
Posts: 90
Joined: Sat Mar 03, 2018 12:07 pm
Contact:

Re: [0.17.45] Combinators allow lua to set their signals to logic signals when they shouldn't

Post by Allaizn »

Thanks, I didn't think that 2. or 3. will get resolved fast if at all. I mostly mentioned them for completeness :)

Post Reply

Return to “Resolved Problems and Bugs”