How do I

Get help using Construct 2

Post » Sat Sep 13, 2014 12:08 am

Remove just the last letter or character from a string?

I made my own keyboard for a player entering choosing their name, and I've made it so they can add letters, but I'm trying to get the "delete" button to work now.

Basically I want to make it so that when a player presses the "delete" button, the Dictionary Value that contains their "name" ,for this example, say the name is "Atticus", changes to have the "s" removed, and becomes "Atticu". If they press "delete" again, I want the Value to then become "Attic."

Please help!
B
9
S
2
Posts: 37
Reputation: 739

Post » Sat Sep 13, 2014 2:11 am

You can use something like "left(name, len(name - 1)" to remove the last character of the string.
B
23
S
9
G
3
Posts: 114
Reputation: 3,794

Post » Sat Sep 13, 2014 2:22 am

Thank you!
B
9
S
2
Posts: 37
Reputation: 739

Post » Sat Sep 13, 2014 3:22 am

Herks wrote:You can use something like "left(name, len(name - 1)" to remove the last character of the string.


My string value is called Player.Name and when I replace it in the algorithm you provided, I get a message that tells me I can't use the subtraction sign due to it not being compatible with strings. am I entering it wrong?
B
9
S
2
Posts: 37
Reputation: 739

Post » Sat Sep 13, 2014 4:21 am

left(name,len(name)-1)
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sun Sep 14, 2014 11:17 am

@BabyCave There's a typo in my code above (missing a paranthesis between the len function), just use what @blackhornet provided instead, it should works perfectly out there.
B
23
S
9
G
3
Posts: 114
Reputation: 3,794

Post » Mon Oct 13, 2014 11:12 pm

Thanks!
B
9
S
2
Posts: 37
Reputation: 739


Return to How do I....?

Who is online

Users browsing this forum: adamebastin, Bro7hers and 7 guests