How do I make a string divider

Get help using Construct 2

Post » Fri Mar 20, 2015 6:32 am

I understand that question maybe very-very easy but I can't formulate my search query correctly.
I'm not a newbie in construct but I never need to solve this kind of problem earlier.

The question Is about how to divide string into parts with newline divider. But without it.

Example: This is a string in some .json file - "Hello, Commander! Let's do businness blah-blah-blah. Good Luck, Commander!"
I want to read it and apply to Text object, but to make phrase "Good Luck, Commander!" on a newline.
No problems with reading. How to make a newline? Is there a way to replace text with some special symbols (for example, in Pascal it was #13+#10) to make it happen?

IMPORTANT! Arranging and reading 2 different strings and divide it with newline expression IS NOT A VARIANT!!! String is solid. We need to tear it apart with something, that can replace newline.

The other question is how to make this through edittime?
In Construct Classic for Text object we can open small window with MemoBox and write all text we want, needed amount of strings etc.
In C2 we have just 1 string TEXT.. and no ways to put newline string here. Or there are some ways? Can you help?
B
8
S
1
Posts: 72
Reputation: 606

Post » Fri Mar 20, 2015 8:59 am

Have you tried using System Expression: tokenat?

System Expression: tokenat
How Do I Recognize "newline" for "tokenat"
B
18
S
3
G
3
Posts: 109
Reputation: 2,784

Post » Fri Mar 20, 2015 9:09 am

See this manual page: https://www.scirra.com/manual/126/system-expressions

Here you find the expression replace(src, find, rep)

So in your case you should be able to do this ex. "Hello, Commander! Let's do businness blah-blah-blah. ###Good Luck, Commander!"

replace(yourstring, "###", "" &newline &"")
Frosty Elk AB
www.frostyelk.se
Have no fear, We come in peace!
B
13
S
3
G
1
Posts: 106
Reputation: 1,169

Post » Fri Mar 20, 2015 10:28 am

Yeah, I know tokenat expression.. and I just forget about it.
Thank you! I think it will be better using it with tokencount at the same time!

Question with edittime is opened.
No ways to edit Text object row-by-row? Only using Set text action?
B
8
S
1
Posts: 72
Reputation: 606


Return to How do I....?

Who is online

Users browsing this forum: stevenode, tarek2 and 12 guests