[r119] Array Curvalue comparisons

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Edit: Found the bug specifically, other issue was improper coding

    Link to .capx file (required!):

    docs.google.com/file/d/0B7mHJO1CK--NQ0tNeFdEVVlxclU/edit

    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 x64

  • 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.

  • Got the other issue working, apparently needed proper sub-tree of events to check.

    scirra.com/forum/topic64516_post395651.html

    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 title

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)