Inspiration from: https://feedback.minecraft.net/hc/en-us/community/posts/360038138992--data-modify-append-to-concatenate-two-strings
A string in NBT-data could be treated as an array of "chars", so the individual characters will just be integers. Indexing a string will yield an integer – the char-code of the character at that index. So strings are just integer-arrays, just rendered as text.
Examples:
- data get storage main Foo[0] -> Yield the char-code of the first index.
- data modify storage main Foo (append/prepend) from storage main Bar[] -> Ap-/Pre-pend all chars from "Bar" to "Foo".
- data modify storage main Foo[0] set value 0 -> Set the first character to 0 (i.e. "\u0000").
If all the above ideas are too farfetched, maybe consider adding a new operation for "data modify" like concat?:
- data modify storage main Foo concat from storage main Bar -> Set "Foo" to be made out of the current "Foo" string concatenated with "Bar".
PS: What about array slicing ;) ?:
- data modify storage main Foo set from storage main Bar[1:3] -> Set "Foo" to be a set of chars of whatever was in range from index 1 until 3 of "Bar".
Please sign in to leave a comment.
1 Comments