TransWikia.com

Put an execute command inside another execute command

Arqade Asked on January 16, 2021

Is it possible to put a "double conditional" in a command block (two execute commands in the same command), like so:

/execute foo run execute bar run command

Is this possible?

One Answer

Yes, it is possible. In fact, a /execute command with multiple parameters remains functionally the same if you add the words run execute in between each parameter.

For example, these two are equivalent:

/execute as @p at @s if entity @p[distance=..10] run say Hi!
/execute as @p run execute at @s run execute if entity @p[distance=..10] run say Hi!

Therefore, there is no need to place multiple /execute commands within each other. It remains the same putting all the parameters in one command.

For your double conditional, all you need to do is include multiple if/unless parameters:

/execute if entity @p[tag=tagA] if entity @p[tag=tagB] run say hello worl

Correct answer by ExpertCoder14 on January 16, 2021

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