1

Actually, when I'm putting the command

/execute @e[name=Mark] ~ ~ ~ /execute @e[name=Mark] ~ ~ ~ /scoreboard players set @e[name=Mark] detect 1

I'm expecting that if only these two same name entities where together then the scoreboard will be "1". But it doesn't, cause it turns to "1" even if I summon only a single "mark" in my world.

  • Nice try! However, you're experiencing this because @e selects all instances of that entity, including itself, which is the same reason why @p executed by a player is himself. Try putting some sort of secondary identifier. – aytimothy May 28 '17 at 0:27
1

Nice try! However, you're experiencing this because @e selects all instances of that entity, including itself, which is the same reason why @p executed by a player is himself.


Try making your detection additive.

In a repeater (as in not Redstone Repeater, but the Repeater and Chain Command Blocks) chain, do:

/scoreboard players set @e[name=Mark] detect 0
/execute @e[name=Mark] ~ ~ ~ /execute @e[name=Mark,r=__] ~ ~ ~ /scoreboard players add @e[name=Mark] detect 1

Now, all you need to do to select all the Marks that are nearby (within r=__ blocks) is to test for anyone with a score of at least 1.

/execute @e[score_min_detect=1] ...

Why this works?

This is because if we are to only have one Mark, his score would always be one since he's the only one executing it.

If there are multiple nearby Marks, then the /scoreboard players add will stack and obviously yielding scores greater than 1.

As for why wouldn't this go into infinity? It's because we reset it after every redstone tick:

/scoreboard players set @e[name=Mark] detect 0
  • @ArJhi If my answer is the correct answer, please mark it as correct using the green check mark. Otherwise please state what you need clarification. – aytimothy May 29 '17 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.