After reading this question and the answer by Simon Meusel I started to wonder how one would go and join two lines of conditional command blocks.
As an example, let's say that I want to run a series of commands at dawn (daytime 0-1000) and dusk (12000-13000). I use the /stats
command to store the value of /time query daytime
in a dummy objective (daytime) on a dummy player (#DAYTIME).
I set up two command blocks to test if the daytime is correct:
/scoreboard players test #DAYTIME daytime 0 1000
/scoreboard players test #DAYTIME daytime 12000 13000
I can use conditional chain command blocks to run whatever I'd like from here. But if there's a lot of commands, I'd rather not place every command block twice. Is there a way to join two conditional command block lines, i.e. create a logical OR using command blocks, without resorting to comparators, redstone dust, or the laggy like? Summoning redstone blocks is okay, as long as it is properly reset every tick.
Best Answer
You can use CommandStats to simulate an OR gate while reducing the amount of required command blocks (since you'd essentially be running two commands for the price of one).
Prerequisites
Objective to hold the CommandStats result.
Single armor stand to summon, which could also be used for other chains that needs it (as its score is to be reset at the beginning of the chains). This will be the entity subject to CommandStats.
Mechanism
Example mechanism (you can swap out the impulse for a repeating block):
Command blocks 2 and 3 will be the initial conditional blocks, where if either are successful you would run more commands. Place a temporary command block above each of them, place the following command inside it, and activate it (you would otherwise just run the command yourself, but the character limit was exceeded):
Now if either of those two commands run, the armor stand will have their "Condition" score set equal to the number of successful iterations of the command.
However, it will only target the armor stand if it has a "Condition" score of 0. This means that if either of them are successful, the score will be 1 and will remain at 1 even if the next command block is unsuccessful.
Commands
The following are the commands for the example mechanism above.
Set the armor stand's "Condition" score to 0. This is needed so it can be targeted by this chain again.
One of the conditionals to check. The success of this command will trigger its stored CommandStats.
The second conditional to check.
After the conditionals have finished, the armor stand will have a score of 1 if either of them were successful. You can then detect this armor stand with a score of 1.
Command(s) to run if either of the conditionals were successful.