Can someone break down this expression for me?

Get help using Construct 2

Post » Thu Feb 07, 2013 3:02 pm

left(SourceText.text, len(DestText.Text) + 1)

from

http://www.scirra.com/forum/typewriter-text-effect_topic45272_post283408.html?KW=#283408

It's about scrolling text, and I would like to know a few things, but a full breakdown would be amazing.

Why does .text have to be after everything?
How exactly does this copy out sourcetext to desttext (the full and blank text boxes respectively)?

Trying to learn so I know the raw details and can utilize my own spin on it.Awakening2013-02-07 15:19:00
B
9
S
3
Posts: 148
Reputation: 1,738

Post » Thu Feb 07, 2013 4:30 pm

.Text is getting the text out of the textbox object.
len(x) gets the length of the text.
left(X,Y) gets the left most text from X, up to Y characters.

So...
The text you want to show is in SourceText.Text.
We want to find out how much text is already in the destination and get one more character: len(DestText.Text) + 1
We get that many characters from the source: left(SourceText.text, len(DestText.Text) + 1)

If you walk through a couple of cycles, to start there is no text in the destination, so len(DestText.Text) = 0. We add one, and we want to get 1 character from the left of the source string: "N"

The next iteration, the (len(DestText.Text) = 1. Add 1 and we get the 2 left most characters from the source: "Ne"
Next: "New"
etc...

The action is based on the fact that we need one more character from the source than the destination already has.
ImageImageImage
B
67
S
19
G
124
Posts: 3,214
Reputation: 74,415

Post » Fri Feb 08, 2013 3:09 am

I really appreciate that! THankyou!
B
9
S
3
Posts: 148
Reputation: 1,738


Return to How do I....?

Who is online

Users browsing this forum: GSquadron, jeffige, MarkThomas, MisterAqua, Nifl, paala and 23 guests