How do I get a certain digit from a number?

Get help using Construct 2

Post » Thu Feb 11, 2016 11:53 pm

How can I get a certain digit, say a, from a number, say b? I used to program often in python, and in python there's expression, "string"[1], which returns the first letter of the string. However, I can't find that in Construct 2.
B
10
S
2
Posts: 20
Reputation: 622

Post » Fri Feb 12, 2016 12:06 am

to get W in Woodland use action
--------------------------------> left(Woodland,1)


say as "string"[1]
variable = "Woodland"

variable[1] ;) python

--------------------------> system set A to left(variable,1) construct 2
Image
B
33
S
10
G
2
Posts: 303
Reputation: 3,539

Post » Fri Feb 12, 2016 2:02 am

I'm not sure what I'm doing wrong, but for some reason I'm getting absurd numbers when I run this code:

subtract from CurrentAnswer
int(right(str(CurrentAnswer),2))

What the code should do is get rid of the number on the far right, help please?
B
10
S
2
Posts: 20
Reputation: 622

Post » Fri Feb 12, 2016 2:38 am

Substract
Image

12345-5=12340
12340-0=12340
12340-0=12340
etc

Set
Image

12345
1234
123
etc
Image
B
61
S
23
G
7
Posts: 1,463
Reputation: 10,690

Post » Fri Feb 12, 2016 3:06 am

Sometimes, programming can make you feel very stupid. This is one of those times. Thanks so much!
B
10
S
2
Posts: 20
Reputation: 622


Return to How do I....?

Who is online

Users browsing this forum: Moordhuis, RetroSpock, TRMG and 7 guests