How do I use a command block to add coordinates to another command block?
In the map I'm making, players will have to choose which items to switch. In this case, I will clone the first block over to the side, clone the second block to the first block's position, and clone the first block to the second block's position. I know this works, however, players will choose which blocks to switch. In this case, whichever buttons they press will set up the command blocks to work. This means that I will need to add coordinates to a given command without removing the command. Is this possible?
Best Answer
Yes, this is possible. You can update the blockdata of the command block. Try something like this command:
/blockdata [X, Y and Z of the command block you want to change the command of] {Command:"/COMMAND_WITH_NEW_COORDINATES"}
Pictures about "How do I use a command block to add coordinates to another command block?"



How do you enter coordinates in a command block?
To make your command block run multiple commands, you will need to summon FallingSand or falling_block (depending on your version of Minecraft) with command blocks and redstone blocks for each command. The command blocks will be stacked one on top of the other and contain the individual command.Minecraft Command Basics: /tp and Coordinates
More answers regarding how do I use a command block to add coordinates to another command block?
Answer 2
I think you're going about this the wrong way. Instead of trying to change the hardcoded coordinates inside a command block, I'd suggest using relative coordinates and /execute. So when the player presses the first button, it summons an armor stand called Block1 at the location. When they press the second, it summons one called Block2. Then all you need to do is clone blocks relative to Block1 and Block2 and you've got what you need without modifying any commands at runtime :)
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Anete Lusina, Sora Shimazaki, Vanessa Loring, Ivan Babydov
