3

Imagine that one day you decided to make an army of Mecha Combiner Robots in minecraft using commands. Each robot is made of 5 armor stands, CustomNamed mechahead, mechabody etc...A lot of em, yes

Then you spawn a few dozen of them in, just for testing purposes, and try to command one to raise their arm by teleporting an armor stand CustomNamed mecharightarm up a bit and... every single one of them raises their arm.

This is the kind of a problem that I ran into today, and a lot of times before when commands weren't as advanced as today, and just can't seem to be able to solve.

The logical solution is to break the entities up into separate sets, for instance by giving each armor stand an ID with scoreboard. But then, how does one select entities that have scores equal to another entity?

What are the solutions to running commands on sets of entities rather than just one?

  • 1
    Ehm that's six armor stands not five ehm – Quijibo Jul 5 at 18:39
2

I think that I understand your problem, and I think that this couod help you.

/execute as @e[tag=mechabody] at @s if score @s ID = #target ID as @e[tag=mecharightarm,sort=nearest,distance=..10] if score @s ID = #target ID run tp @s ~ ~ ~ ~ ~

With this command you are able to select a mecha via /scoreboard players set #target ID <targeted bot>.
Then you are able to execute the first command, only change the tp parameters, the coordinates are relative to the mecha's body.
Maybe you need to modify the distance selector a bit for your needings, but I think, that the arm would never be further than ten blocks feom the body.
You can use this command also for the other components of the robot. Just make sure that all parts of the robot get the same ID.
And, but I think this is clear, you need to add a scoreboard objective called ID first, with has to be a dummy scoreboard.
Hope that i hepled you.

Commander guy

  • What purpose do the sort and distance parameters serve in this part? (as @e[tag=mecharightarm,sort=nearest,distance=..10]) – user232393 Jul 5 at 19:04
  • In 1.12 you needed to subtract the scores and check for 0, now it can luckily be done much easier. – Fabian Röling Jul 5 at 21:20
1

This command will teleport any armor stand that is a right arm if the scoreboard objective ID has the same value as any armor stand specified in the first part of the command.

/execute at <target selector for the body of every mech that should move the right arm>
         as @e[type=minecraft:armor_stand,name=mecharightarm] 
         if score @s ID = @e[type=minecraft:armor_stand,name=mechabody,sort=nearest,limit=1] ID 
         run tp @s <Position relative to body>

This uses the body as a kind of root, you would target the mech by targeting the body armor stand. If two mechs have their body in the exact same position, then the command may get confused and move the arm of the wrong mech.

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.