How do I change the last letter in text?

Get help using Construct 2

Post » Mon Sep 07, 2015 3:43 pm

Good morning. I hope what I am trying to do is possible...

Sprite.X has four variables.
Variable 1 = P11T1
Variable 2 = P02T1
Variable 3 = B01T1
Variable 4 = D08T1

The action I want is this...

If Variable 1 ends in "T1"
and If Variable 2 ends in "T1"
and If Variable 3 ends in "T1"
and If Variable 4 ends in "T1"
then choose randomly Variable 1, Variable 2, Variable 3, Variable 4 and change those last two letter to T2


So basically check if all four variables end in T1, if so pick a random variable and amend the text to end in T2 instead. Thank you!
B
9
S
2
Posts: 56
Reputation: 668

Post » Mon Sep 07, 2015 4:02 pm

Would either of these two work?

If Variable 1 = ????"1"

If Variable 1 = "????1"
B
9
S
2
Posts: 56
Reputation: 668

Post » Mon Sep 07, 2015 4:41 pm

If it's always 2 characters at the end then, if the text was in a variable called 'mytext', then you can get the last 2 characters using:

right(mytext,2)

IF you need more info, read the Text section of System Expressions in the manual.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Mon Sep 07, 2015 6:07 pm

Thank you.
B
9
S
2
Posts: 56
Reputation: 668


Return to How do I....?

Who is online

Users browsing this forum: evillair, Yahoo [Bot] and 6 guests