X

NOTICE

Are you sure you want to report this?

We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.

42

'/data modify [...] append' to concatenate two strings

7 Comments

Post a new comment:

Please sign in to leave a comment.

  • 0
    Xavier Hervy commented
    Comment actions Permalink

    Would be nice for nbt array too

  • 1
    Thick propheT commented
    Comment actions Permalink

    This would be really useful for appending the player's UUID to the name field of a structure block e.g. "minecraft:some_structure/00000000-0000-0000-0000-000000000000". That way, you could allow each player to have a unique copy of a structure.

    I think this is a reasonable addition, since strings are treated as collections in many languages.

  • 1
    RELapis commented
    Comment actions Permalink

    I think strings should just be treated like an array of characters, so you could use append, prepend, insert, and also specify the [0] index.

  • 0
    Teixon commented
    Comment actions Permalink

    This would make them need to change strings to be treated as some sort of array-type. If you want to add elements to any array you need to use a value of the type that array will yield. In this case, maybe a new "character"-type? Otherwise saying "append string2 to string1" implies that you want to have an element within "string1" that is of a different type (an array-type again in this case) and that is not what you want.

  • 0
    Teixon commented
    Comment actions Permalink

    What I could see them do is add a new operation like "concat": data modify (block <pos>|entity <target>) <path> concat (from (block <pos>|entity <target>) [<path>]|value <value>)

    And both your paths and value need to yield a string ofc.

  • 2
    Comment actions Permalink

    Great Idea. Would be really useful when manipulating data. If numbers would also be automatically cast into Strings, like they are with the score selector in the chat or in signs, you could do some really interesting stuff with scores.

  • 0
    Splox Fox commented
    Comment actions Permalink

    FYI McTsts did some command trickery that allows you to convert a string to an array of characters. The only missing link is turning these characters back into a single string.