TransWikia.com

How do I get a random output?

Arqade Asked on November 28, 2020

What is the most efficient way to get a random output with my commands? In Java there are tons of ways to do this, but a lot of them don’t seem to work for Bedrock Edition.

One Answer

Concept

The @r selector can be used to pick a random player. What some people do not know, though, is that if you specify another type other than player you can have it select things other than players.

Commands

Lets say I want to have my machine output white or black wool. We have 2 command blocks with a tick delay of 7 (if we don’t have a tick delay it will sometimes fail) with the command:

setblock ~ ~1 ~ air

Now chains attached to them with these (one will be white, one black):

setblock 5 5 5 wool 0

and

setblock 5 5 5 wool 14

Now above the original impulse command have air and a block above that bedrock with armor stands on top of each. Name the armor stands the same thing. I will use test.
Now somewhere else have a command block that says:

execute @r[type=armor_stand,name=“test”] ~ ~ ~ setblock ~ ~-2 ~ redstone_block

Now when that command block is activated, it will place either a white or black wool block at 5, 5, 5!

Correct answer by Penguin on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP