0

I'm trying to setblock a command block with variable data in it. I want to make a variable sized array with an armor stand, and read a custom tag at a variable position. This position should be stored in a scoreboard as well.

Further information:

  • Minecraft version 1.13.2
  • Singleplayer mode

I've already tried this command:

/setblock ~ ~2 ~ minecraft:command_block{Command:{"text":"execute store result score posN replay run data get entity highfrequent Pos["},{"score":{"name":"#this","objective":"replay"}},{"text":"]"}} replace

But it doesn't work. It couldn't place the block, and I think I did something wrong with the JSON syntax.

My objective is to have an array which I can read at a variable position.

If anybody has an idea of how to do this, I would be glad to hear it.

3
  • What's the actual error? Hard for us to help you if you don't give us all the information.
    – MBraedley
    Commented Jul 8, 2019 at 17:04
  • Even if command blocks allowed JSON as their command, you forgot the quotation marks and square brackets around it. Commented Jul 8, 2019 at 18:32
  • It seems to me the title and your 'objective' (which I realize was constructed as an edit) do not really overlap a lot: could you rewrite the title to cover the goal of your question?
    – Joachim
    Commented Jul 27, 2019 at 6:50

1 Answer 1

1

The command inside a command block is a regular string, not a JSON component. Since there's also no way to convert a JSON component into a normal string, you can't use it as the command inside a command block.

3
  • What did you actually want to do with that? Maybe there's still a way to do what you want, but not with variable command blocks. Commented Jul 8, 2019 at 18:39
  • I try to make an array which I am able to read at an variable position. Commented Jul 9, 2019 at 16:03
  • So you mean just like the arrays in NBT? You can already do that, items allow arbitrary data in their tag NBT tag. Commented Jul 10, 2019 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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