I was trying to set the scoreboard values of certain entities with a command like
/execute @e[type=ArmorStand] ~ ~ ~ detect ~ ~-1 ~ stone 0 scoreboard players set @e[c=1] myObj 1
and I noticed that it updated my score instead of the armor stand's.
It was my understanding that the selector
@e[c=1] selected the nearest entity, which should be the armor stand that is executing the command. To test this, I used the command
/execute @e[type=ArmorStand] ~ ~ ~ detect ~ ~-1 ~ stone 0 say @e[c=1]
and it said "Armor Stand", not my name.
This seems inconsistent. Is there a reason for this behavior or is it a bug? Is there a way to reliably select the entity that is executing the command?
P.S.: The same thing happens if I place a command block next to the armor stand and let it execute the commands:
scoreboard players set @e[c=1] myObj 1 targets me (even though I am further away), but
say @e[c=1] says "Armor Stand".