Automatically convert to int()

Discussion and feedback on Construct 2

Post » Thu Sep 19, 2013 10:11 am

I think ryackov means he makes a global variable first. During this he chooses it to be a text or a number or a bool. He chooses number. So C2 knows it's a number.

Then he sets the textbox's text to that global variable. Thus he feels c2 should remember the value was a number in first place, and when he retrieves it from text object, it should automatically be type-casted.

But I do not think this is how textbox works. Due the explanations by the above, anythink you put into a textbox will have to be converted into text. Thats the reason of textbox. It enables you to do various things with text, and to be able to do so, the number is turned into text. What if you store 10 to textbox, then set text to self.text & " points"? now the value inside is "10 points" and when you retrieve it there is no way for c2 to decide what to keep and what to discard.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Thu Sep 19, 2013 10:45 am

Actually, @ryackov is right. There's an inconsistency, there's partly auto-casting, maybe by design @Ashley?
I never stumbled upon it, because I always use variables of suitable types. With this small 1-event-project you can test it:


Preview it and enter the letter a. It will say NaN as expected. Enter the letter 1 and it will return the number 1. With all issues that I mentioned earlier in my posts. (1.34 gets 1; 1,35 gets 1; 1.a gets 1 etc.)

I didn't see this behavior before and would like to know if it's by design, and if so, why? (I think, it doesn't help much and introduces other issues)
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: Artpunk, BadMario, jobel and 3 guests