#Getting the length of an nbt array?

1 messages · Page 1 of 1 (latest)

earnest charm
#

Is this possible without using a loop?

earnest charm
#

Should I just make it so that the array has its length in its first element and the rest is its elements?

earnest charm
silver talon
#

Yes, you can do /data get <source> <path to array>, if you store the result of that command in a numerical NBT tag or a scoreboard it will be the length of the array. You can do the same for strings.

earnest charm
weak yarrow
#

You can also do execute store result score <entity> <score> if data <sorce> <path to array>[] make sure you put [] at the end of the path to the array

#

The [] means you want to select all items in the array and not the array itself

tacit pelican
#

That's what was said previously

#

You also don't need the brackets

weak yarrow
#

No it was said for the data get comand

#

And then you do need the brackets

tacit pelican
#

It was phrased a little differently to how you did, but it explained the sane thing

#

Anyway, the point is that they know how to do it now, so I'm going to close this post

weak yarrow
#

Ol