A single alert per X seconds

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
User avatar
Light
Filter Inserter
Filter Inserter
Posts: 678
Joined: Mon Oct 10, 2016 6:19 pm
Contact:

A single alert per X seconds

Post by Light »

I'm hoping someone could assist me in what's probably a simple combinator circuit, but I couldn't find anything about.

My goal is to have the speaker announce an alert for just a second or two, then pause for X seconds before checking if the condition is still true before sending another alert. To describe this in steps:

1. Accumulator is less than 50%
2. Speaker alerts low power for a second or two
3. Speaker then goes quiet for 5 seconds
4. If the accumulator is still <50% then resend the alert signal to the speaker
5. Repeat this sequence until accumulator is >50%

There are times where I'm unable to deal with an alert straight away and thus it annoys me for several minutes of constant noise. Being able to space out the alerts would prevent headaches yet still keep me informed of the problem.

This is even more essential for alerts with vocals, such as the C&C Low Power Alerts Mod which my design is intended for. If someone can assist in designing this then I'm sure to use alerts around the factory a lot more frequently with my ears thanking them for the relief.

BlakeMW
Filter Inserter
Filter Inserter
Posts: 950
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: A single alert per X seconds

Post by BlakeMW »

You need a countdown timer.

Wire a Constant Combinator outputting T = -1 to a Decider Combinator wired to itself and outputting T on the condition T > 0

When another Combinator sends a T value (say 600) to this setup, the T signal will count down by 1 each tick until reaching 0 then it will remain at 0.

The Countdown timer is one of the basic constructs which is useful to be familiar with. (Of course there are a ton of ways it can be implemented, sometimes I use a decider with the condition pistol = 0 output T, this counts up or down indefinitely so can be used to know how many ticks it has been since the event last happened, and can be reset to 0 using the pistol signal)

Now when a bad things happen, you have to use a condition like this:
T = 0
AND
A < 50 (assuming accumulator is outputting A)
OUTPUT
T = 600

I assume you know how to do AND conditions using decider combinators. Since this signal can only be sent when T = 0, and it sets T to non-zero, it will only be sent for a single tick.

Finally you can now use the T signal to decide if an alarm should be played, on the speaker use a condition like T > 480, so when T is between 480 and 600 it plays an alarm, when it's under 480 it doesn't. As long as the bad thing condition keeps being true, the timer will cycle between 600 and 0.

This is the logic I use to feed nuclear reactors not more often than every 200 s, and then only when the steam tank is depleting.

User avatar
Light
Filter Inserter
Filter Inserter
Posts: 678
Joined: Mon Oct 10, 2016 6:19 pm
Contact:

Re: A single alert per X seconds

Post by Light »

BlakeMW wrote:
Fri Mar 22, 2019 8:55 am
I assume you know how to do AND conditions using decider combinators.
Not in this situation I don't.

I've gotten the countdown timer functioning perfectly fine, but it all falls apart when I hook it up to the rest. I'm unsure how to output 600 without screwing with the AND function entirely, so the numbers are all a jumbled mess. It just constantly counts up into the hundreds of thousands whichever way I try to wire it up.

I've followed what you've said to the letter, but I'm obviously still missing something here.

BlakeMW
Filter Inserter
Filter Inserter
Posts: 950
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: A single alert per X seconds

Post by BlakeMW »

Use a pair of decider combinators like this:

A < 50: OUTPUT B = 1
T = 0: OUTPUT B = 1

Wire the outputs of those combinators into a 3rd Decider relying on "implicit summing" of signals:

B = 2: OUTPUT T = 1

(Alternatively, you can use an Arithmetic Combinator, producing a "B=1" and "C=1" signal, and then in a arithmetic combinator use "B AND C: OUTPUT T" this works fine but isn't as clean if you want to do an AND condition on more than 2 signals)

Then wire that signal into an arithmetic combinator:

T * 600: OUTPUT T

Post Reply

Return to “Gameplay Help”