How do I change data in a tokenat expression?

0 favourites
  • 3 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • If I fill a cell within an array with a token expression, say,

    set at x: 0

    value: "apples;oranges;bananas"

    how would I be able to change any ONE of these words in another action?

    like for example in the future if I wanted to just change apples to kiwis, and not affecting the rest of the expression.

    So that I would have: "kiwis;oranges;bananas"

    HELP PLS

  • Assuming you will only have one instance of a word in the text..

    text = "apples;oranges;bananas"

    changedtext = System -> Replace( text, "apples", "kiwis" )

    or just..

    text = System -> Replace( text, "apples", "kiwis" )

    I just used changedtext for clarity.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Might be better to just use an array (if sequence matters) or dictionary (if it doesn't).

    You could also easily import such a token separated string into an array:

    array set size 0,1,1

    for 1 to tokencount(string, "separator"):

    array push at back of x "tokenat(string, loopindex-1, separator)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)