1

How to execute commands conditionally within a function.

ElJazzMaster 5/2/21 1:30 am
135
5/2/2021 7:34 am
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! :)
Posted by
ElJazzMaster
Level 6 : Apprentice Miner
0

  Have something to say?

JoinSign in

1

HoboMaggot
05/02/2021 7:34 am
Level 55 : Grandmaster Blob
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.

execute store result score @a[tag=<trigger_tag>] check_andesite run clear @s andesite 0
This 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
1

Welcome