Iterate through lines of text

Get help using Construct 2

Post » Wed Feb 01, 2012 5:45 am

I want to set an array with text then iterate through it - all the tutorials and posts I'm seeing about arrays are over my head or off topic. I know I can do this manually with a long slew of events but I'd rather do this with an array and an expression. I just don't know where or how.

for example - at 5 seconds:

"good start"

at ten

"keep going"

at fifteen

"almost there"

etc - thanks!
B
4
Posts: 13
Reputation: 576

Post » Wed Feb 01, 2012 6:12 am

You can use TokenAt() to retrieve part of a string so long as there is a delimiter.

For example, if you have a string "M1,M2,M3"

then tokenat(string,2,",") will give you "M2"Tokinsom2012-02-01 06:14:56
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Feb 01, 2012 9:52 am

Yeah tokenat definitely.
With array it's a pain 'cause you have to set each lines with one action
[code]Array: set value at (0) to "good start"
Array: set value at (1) to "keep going"
etc[/code]

With tokenat you just do a
[code]Global text dialog = ""
System: Start of layout
-> Set dialog to [insert your tokenized text][/code]
And then call each token as Tokensom (hehe) said

My little advide :
Build your string with newline as separator
[code]dialog = "good start
keep going
almost there"[/code]
And then you can access each of them with tokenat(dialog,[index],newline)Yann2012-02-01 09:53:18
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to How do I....?

Who is online

Users browsing this forum: Skebab, Yahoo [Bot] and 11 guests