[r119] Array Curvalue comparisons

Bugs will be moved here once resolved.

Post » Tue Mar 05, 2013 8:53 pm

Edit: Found the bug specifically, other issue was improper coding
Link to .capx file (required!):
https://docs.google.com/file/d/0B7mHJO1CK--NQ0tNeFdEVVlxclU/edit?usp=sharing

Steps to reproduce:
1. Look at code
2. Run Preview

Observed result:
array.CurValue = 1 doesn't trigger, but array.CurValue > 0 and Array.Curvalue = "1" trigger (could also use Array.CurValue = Int(array.curvalue) to do the same thing.

Expected result:
The result should be one of two things

1: Only array.CurValue = "1" // array.curvalue = int(array.curvalue) should work

2: All conditions should work.

Browsers affected:
Chrome: yes
Firefox: yes/no
Internet Explorer: yes/no

Operating system & service pack: Windows 7 x64

Construct 2 version: r119 x64Thndr2013-03-06 02:39:03
B
15
S
4
G
4
Posts: 294
Reputation: 3,225

Post » Wed Mar 06, 2013 1:12 am

After looking into it, it appears my JSON was full of STRings of numbers instead of numbers themselves.

I was getting away with it working because when you compare anything but Equals, it treats it like an INTegers. So the bug it wasn't what I was trying to do, but that it allowed STRings to be considered Greater or Less Than an INTeger.

Either way, making sure my JSONs are set to INT for my uses here.

The other issue however I'm still troubleshooting to see why it would function like that, as it's comparing specific instances and should trigger per instance.Thndr2013-03-06 01:14:56
B
15
S
4
G
4
Posts: 294
Reputation: 3,225

Post » Wed Mar 06, 2013 2:29 am

Got the other issue working, apparently needed proper sub-tree of events to check.
http://www.scirra.com/forum/topic64516_post395651.html#395651


So only only issue here is that the software uses a STR number for any comparison but exact matching (so array.CurValue=5 will not work on "5", but array.CurValue<6 will work on "5")

Edited original post with a simpler reproduction of the issue and modified the titleThndr2013-03-06 02:38:49
B
15
S
4
G
4
Posts: 294
Reputation: 3,225

Post » Wed Mar 13, 2013 2:34 pm

Closing as by design; Construct 2 does not automatically cast between strings and numbers. Store a number instead of a string in the array if you want your number comparisons to work.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Mar 13, 2013 10:24 pm

I am doing that now.

It was the process I was making arrays had everything converted to string which made things wonky as it would Greater/Less than compare strings to numbers, but not Equal compare strings to numbers.
B
15
S
4
G
4
Posts: 294
Reputation: 3,225


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests