[2.0.28] "Everything" condition is evaluated wrong for one tick after a change

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
meganothing
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Sep 15, 2016 3:04 pm
Contact:

[2.0.28] "Everything" condition is evaluated wrong for one tick after a change

Post by meganothing »

I added a condition to an inserter sourcing from an initially steel chest to only be enabled when "Everything" is greater than 100 in that chest.

When I now manually put a stack of 50 steel bars (or other items) into that chest the inserter turns on exactly once even though the condition is not met at any time. In the picture you can see the bottom two had been doing this and because of hand size 2 of the inserter there are 2 items on the belt for the steel bar and the iron bar example.

The first one with the rails did not do this because I put the 50 rails into it before adding electricity to the inserter.

I would expect the condition never to be true and the inserter therefore never having been activated. First it would be 0>100 = false. Then I insert the stack of 50 items and 50>100 = false again. As there are never more than 50 items in the chest the condition should never be true and the inserter should never activate

The number of items does not really matter much, but the chest has to be empty initially.
pic1.jpg
pic1.jpg (163.75 KiB) Viewed 535 times
pic2.jpg
pic2.jpg (81.64 KiB) Viewed 535 times

I also added the save as an attachment so you can test it with my setup:
_autosave3.zip
(7.43 MiB) Downloaded 19 times
Muche
Smart Inserter
Smart Inserter
Posts: 1006
Joined: Fri Jun 02, 2017 6:20 pm
Contact:

Re: [2.0.28] "Everything" condition is evaluated wrong for one tick after a change

Post by Muche »

Works correctly.

Inserter is initially enabled when the chest is empty, because the condition Everything is true if there are no signals.
See wiki.factorio.com/Circuit_network / viewtopic.php?p=633480.
meganothing
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Sep 15, 2016 3:04 pm
Contact:

Re: [2.0.28] "Everything" condition is evaluated wrong for one tick after a change

Post by meganothing »

Thanks, this explains it partly. I.e. that the inserter is actually active at the time the box is empty.

But it is still a race condition since at the first moment that the inserter sees a non-empty box the inserter conditional still must see an empty box.

This could be explained two ways: Either the inserter has a delay for turning off or signals propagate with 1 tick per combinator(*) (i.e. all combinators show the results from the data of the inputs from the previous tick). I don't see this information in the wiki, might be nice to have there.


* including the built-in combinator in an inserter
Muche
Smart Inserter
Smart Inserter
Posts: 1006
Joined: Fri Jun 02, 2017 6:20 pm
Contact:

Re: [2.0.28] "Everything" condition is evaluated wrong for one tick after a change

Post by Muche »

I did not find a mention to delay/latency directly in the game.

In the wiki I found:
Circuit network wrote: The value for [signal] will rapidly (but not instantly) shoot upward. (The rate at which it climbs is determined by the current tick rate.) This technique can be combined with decider combinator logic to make electronic clocks, gates, and other systems; see Combinator Tutorial for advanced techniques.
Decider combinator wrote: With both the arithmetic and decider combinator, there is one tick (60th of a second) of latency before the output signal is ready to be used as an input into a circuit network.
Tutorial:Combinator tutorial wrote: Combinator logic works because Factorio only updates at 60 times per second. Logically, each update tick is separated into two steps. In the first step, all combinators first read the input from the connected network(s), perform their computations. This produces an output value for every combinator. The tick update concludes with the second step, where the values of each network will be updated as the sum of all connected values.
When logic values are computed by combinators, the outputs are not recognized by the circuit network until the following step. So when a decider combinator is used to detect a certain input condition, its output value will not take effect on the circuit network until the next step. This behavior is important to remember and can result in sequencing errors and significant delays when multiple combinators are connected in series.
Tertius
Smart Inserter
Smart Inserter
Posts: 1273
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: [2.0.28] "Everything" condition is evaluated wrong for one tick after a change

Post by Tertius »

meganothing wrote: Tue Jan 14, 2025 1:21 pm But it is still a race condition since at the first moment that the inserter sees a non-empty box the inserter conditional still must see an empty box.
The solution for your case is using ANY > 0 instead of the EVERYTHING > 0. ANY stays false in comparison as long as the condition isn't satisfied.
Post Reply

Return to “Gameplay Help”