1
How to execute commands conditionally within a function.
What I want to do is simple, I know how to do it using conditional chain command blocks, but I don't know how to do it within a function.
All I want to do is have one command execute if the one before it executes successfully.
For example:
clear @p andesite 1
scoreboard players add @p points 1
Simple, if it can clear the player of one block of Andesite, then add 1 point to that player's score, But I can't find anything anywhere that tells me how to do this within a function.
Any help would be greatly appreciated, thanks! :)
All I want to do is have one command execute if the one before it executes successfully.
For example:
clear @p andesite 1
scoreboard players add @p points 1
Simple, if it can clear the player of one block of Andesite, then add 1 point to that player's score, But I can't find anything anywhere that tells me how to do this within a function.
Any help would be greatly appreciated, thanks! :)
1
Pretty sure you need another scoreboard for others to check if the person has more than one and then use your 2 commands you've stated.
This will detect how many andesite blocks the player has
and then
Putting all of this in order in the function should get the result you desire per function calling
execute store result score @a[tag=<trigger_tag>] check_andesite run clear @s andesite 0This will detect how many andesite blocks the player has
and then
execute as @a[tag=<trigger_tag>] if score @s check_andesite matches 1.. run clear @s andesite 1execute as @a[tag=<trigger_tag>] if score @s check_andesite matches 1.. run scoreboard players add @s points 1execute as @a[tag=<trigger_tag>] if score @s check_andesite matches 1.. run tag @s remove <trigger_tag>Putting all of this in order in the function should get the result you desire per function calling
