[SOLVED] How come I keep getting the message, Invalid Value?

Get help using Construct 2

Post » Mon Apr 14, 2014 11:09 pm

How come I keep getting the message, Invalid Value? I have a textbox and its type is number and it also has an instance variable. I want to set the numbers entered in the textbox as the instance variable value but each time I try to I get the message: Invalid value for "Value". You can not set a string to the number variable '(name of variable)' - use int() or float() around the expression to convert. I set the code to: Set Value for (Variable Name) to (object_name).Text but that does not work. Also, I do not want to change the type of the textbox because that would screw up my game. Help would be greatly appreciated!
Last edited by HZGaming on Tue Apr 15, 2014 1:45 am, edited 1 time in total.
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Mon Apr 14, 2014 11:18 pm

I'm not entirely sure what you are trying to say.

Upload a screen shot of what is happening wrong and your code and perhaps we can get a better idea.
B
8
S
1
Posts: 76
Reputation: 949

Post » Mon Apr 14, 2014 11:28 pm

Here is the screenshot @izicial:
You do not have the required permissions to view the files attached to this post.
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Mon Apr 14, 2014 11:42 pm

Ok, that's what I though you were doing.

You have to change the variable type to text. It can't be number. Doesn't matter what else you have to change because of it but if you want it to work that way then it must be a text variable and not number.
B
8
S
1
Posts: 76
Reputation: 949

Post » Mon Apr 14, 2014 11:58 pm

@izicial I understand that, thank you but I really want to keep the type number because this textbox is supposed to allow players to enter their amount of money and so I don't want them to be able to enter letters.
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Tue Apr 15, 2014 1:08 am

Change textbox_income.text to a text variable then use int(textbox_income.text) to convert the string to an integer. Save it in a different variable if you want to then avoid having to repeatedly do the conversion.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,228
Reputation: 44,888

Post » Tue Apr 15, 2014 1:45 am

@Collumdium Thank you very much!
B
37
S
14
G
3
Posts: 263
Reputation: 4,270


Return to How do I....?

Who is online

Users browsing this forum: asdtricky, Ashley, brunopalermo, ST314 and 32 guests