Converting strings to integers

Get help using Construct 3!

Post » Thu Jul 27, 2017 7:39 pm

I am working on an RPG and I want the user to type numbers into text boxes and then I want to add those numbers. Is there a way to do this?

Things I have tried:

1.using float()
2.using int()
3.using both int(float())
4.just straight adding the values
5.Screaming at my computer

All of them but the last one created an error basically telling me that strings aren't integers. If you have any ideas I would be happy to hear them :) .
B
4
S
1
Posts: 7
Reputation: 314

Post » Thu Jul 27, 2017 9:56 pm

I guess you're setting a third text object to the result? Convert the texboxes to numbers, add them together, and set the result of be a str again.

set textbox3 text to str(int(textbox1.text)+int(textbox2.text))
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Fri Jul 28, 2017 2:34 am

@R0J0hound Thanks that makes sense, it wasn't an error with addition it was saying the text box can't accept integers. I never would have guessed that, Thanks so much!
B
4
S
1
Posts: 7
Reputation: 314


Return to How do I...?

Who is online

Users browsing this forum: oosyrag and 0 guests