2 identic arrays are different

This forum is currently in read-only mode.
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I'm having a problem with arrays

    I started by making my array directly on events, just to test my game

    <img src="http://i52.tinypic.com/15qt18p.png">

    Then I moved on to creating it on a separate file, so I made an array editor:

    <img src="http://i55.tinypic.com/2ch9xk3.png">

    But then the game stoped working

    I saved both arrays, and they happen to have different sizes:

    <img src="http://i51.tinypic.com/wguhbn.png">

    And different content:

    <img src="http://i54.tinypic.com/bex1j5.png">

    But I loaded each of them into my array editor and both showed the same numbers

    Why is this happening?

  • It could be because the array is stored differently when held in memory than when saved from a text box. However, I notice that you use a 3 dimensional array which can get pretty compicated. Might be worth drawing the 3 dimensions out on paper to note what data is stored where.

    If you're still early in development and need another solution for map saving, I'd recommend using INI files, here is an example cap: http://www.scirra.com/forum/viewtopic.php?f=8&t=1721&p=12302#p12302

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your array editor looks like it's saving the values as text instead of numbers. It shouldn't make much of a difference though as construct easily converts text into numbers.

    However you will run into an issue when you try to add two array values together and they are both text. The text will be concentrated together instead of added numerically. The solution is to convert the values to integers with int().




    Set Text to Array(1,2) + Array(1,3)

    // Text will be "1011"

    Set Text to int(Array(1,2)) + int(Array(1,3))

    // Text will be "21"

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