how to not commence a command depending on player health? [duplicate]
I have a command that simply turns grass into dirt when a player stands on it.
execute @p ~ ~ ~ detect ~ ~-1 ~ grass 0 setblock ~ ~-1 ~ dirt
Is there any way to make this not happen when the player's health is full? (It may not involve any comparators, only command blocks as I am using a single command block generator, therefore it will come with a constant clock as well.)
First, make a scoreboard objective that tracks the player's health:
Create the objective (run only once):
/scoreboard objectives add Health health
Then you run the execute
command as following:
/execute @a[score_Health_min=0,score_Health=19] ~ ~ ~ detect ~ ~-1 ~ grass 0 setblock ~ ~-1 ~ dirt
How this works is that it runs the command for all players with a maximum Health
score of 19
.