[Solved!] Line break in an instance variable string?

Get help using Construct 2

Post » Tue Mar 11, 2014 3:48 am

Is it possible to include a line break in an object's text instance variable? My game includes a text box with appearing "typewriter" text, but words don't wrap until they're long enough to breach the edge of the text box, which can be jarring. I attempted to solve this problem by manually putting in line breaks before these words, but I haven't found a good way to do so.

I'm using instance variables to feed the text box from NPC objects - the NPC contains all of the text that the text box will use for the dialog, and each NPC can have different text, even though they're technically the same object.

I tried adding " & newline & " to the strings themselves, but that proved fruitless.

Does anyone have a solution to this problem?
Last edited by BattleJenkins on Tue Mar 11, 2014 6:34 am, edited 1 time in total.
B
9
S
2
Posts: 28
Reputation: 649

Post » Tue Mar 11, 2014 6:34 am

Solved! By me!

It turns out you can use the "replace" function to replace a character with a line break! So instead of calling the instance variable directly, like I was:

Self.Line1

I called this instead:

replace(Self.Line1, "|", newline)

Now any time I type a |, I get a line break! So easy!
B
9
S
2
Posts: 28
Reputation: 649


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests