5

Context: I installed a train mod for fabric 1.16.5. The mod currently comes with what's called a "Platform Screen Doors", which will open with the train door at the same time.

I am currently trying to play an custom sound with command block when the Platform Screen Door is opened. But since it does not emit any redstone signal, I have used an observer shown below: (Command block not shown) Observer lit up for one tick when the door is opened

This by itself works as intended, where the observer would lit up for 1 tick, delay for 1 redstone tick, then repeat as long as the door is opened.

But I want it to only trigger the command block once, then wait for x seconds before it's allowed to be triggered again.

My thoughts would be to lock the repeater once it's activated, go through a bunch of repeater (for delay), then unlock it, but I can't think of how can I let it unlock by itself.

UPDATE: Hacked my way through it, but I doubt it will be reliable on long runs. My current implementation

Essentially once the observer is triggered, it will:

  1. Lock the repeater
  2. Trigger the command block for playsound
  3. Go through a lot of repeaters (So I can delay it for 20s)
  4. Set "block1" (The pink square) to air to unlock the repeater.
  5. Delay for a bit, then set block1 back to redstone dust for the next use.

Though I still can't think of how can I delay it for 20s without a lot repeaters, I don't want to use Piston + hopper as it creates sounds I also have no idea how reliable setblock command really is Sorry I usually don't touch redstone stuff, any suggestion appreciated!

1 Answer 1

1

To do exactly what you described, you can use a silent non-retriggerable pulse extender: enter image description here enter image description here

The lower pair of hoppers (facing into each other) has 1 item, which decides in which directions items flow in the upper pair. The upper pair (also pointed into each other) has 26 items, which takes 20 seconds to be sent back and forth between the two hoppers. The torch is deactivated when a pulse from the observer comes, allowing the lower hopper to transfer its item, and thus, the timer to start, and will prevent it from restarting if there are no new pulses. Still, every 20 seconds the observer keeps getting triggered, the sound will be made.

What you're looking for, probably, is a simple retriggerable pulse extender.

enter image description here

As long as the observer keeps generating pulses over and over, the signal is active - and the command block activates only when the signal activates first, remains inert until the signal is removed and provided again. That way while the observer 'goes crazy', only one sound is heard. If the observer is off for a second or so, the circuit powers off and will trigger next time the observer does.

Let me add, for interrupting a circuit, like you did with a pair of command blocks, the comparator in subtract mode serves better - insert full strength signal into the side of a comparator and it will stop passing the signal -

enter image description here

...and what you tried to achieve in the beginning before the delay is known as RS Latch circuit, one of simplest memory cells, and it's much easier achieved with two torches or two comparators:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.