How do I change data in a tokenat expression?

Get help using Construct 2

Post » Sat Apr 04, 2015 11:28 pm

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
B
11
S
2
Posts: 91
Reputation: 1,017

Post » Sat Apr 04, 2015 11:47 pm

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.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Sun Apr 05, 2015 11:19 am

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)
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786


Return to How do I....?

Who is online

Users browsing this forum: JaisonAntoniazzi, kseiro and 9 guests