User Tag List

Results 1 to 6 of 6

Thread: Bug with array object : array indexes change

  1. #1
    Clicker Multimedia Fusion 2
    Fusion 2.5 (Steam)

    Join Date
    Feb 2017
    Location
    Switzerland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Bug with array object : array indexes change

    Hello everyone,

    I think I have discovered a faulty behavior in the array object (0-based text array). So, I was working on a rather complicated loop : some kind of breadth-first algorithm, which requires to compare the content of the 4 adjacent cells (x+1;y, x;y-1, x-1;y, x;y+1) from a particular one. I was using the "array indexes" (x and y in my case) to store the current position from which I compared adjacent ones. It wasn't working and it gave me headaches for hours. I tried "printing" everything I could in a list to review some values during the process and then the answer came to me : the array indexes were changing! (without being given the instruction).

    I used some comparisons like this :
    StrAtXYZ( "Array", index x( "Array" ) + 1, index y( "Array" ), 0 )
    StrAtXYZ( "Array", index x( "Array" ) , index y( "Array" ) - 1, 0 )
    StrAtXYZ( "Array", index x( "Array" ) - 1, index y( "Array" ), 0 )
    StrAtXYZ( "Array", index x( "Array" ), index y( "Array" ) + 1, 0 )


    and some expressions like this :
    List : add line Str$(index x( "Array" ) + 1) + ";" + Str$(index y( "Array" ))
    List : add line Str$(index x( "Array" ) ) + ";" + Str$(index y( "Array" ) - 1)
    List : add line Str$(index x( "Array" ) - 1) + ";" + Str$(index y( "Array" ))
    List : add line Str$(index x( "Array" ) ) + ";" + Str$(index y( "Array" ) + 1)


    And somehow, refering to the "index - 1" or "index + 1" seemed to make it change by that amount, but not always. You'll tell me that the array indexes are meant to be used with "write to current position", which is true, but in that case I found it pretty convenient to use them that way. I'm doing a lot of work with arrays (procedural map generation) and I'm starting to wonder if I can trust this object.

    So my solution was to just use some alterable values from an object to store current X and Y instead of the indexes and everything suddenly became fine!

    So my questions are : is this behavior intended? (well, I don't think so obviously, but still...). Is it a known bug? Have you ever encountered it? If not, I could share a .mfa, but I don't want to share my whole project and isolating the problem would take some time, I'm not sure I want to do that if it's not of any help to anyone.

  2. #2
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    919
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I've had some weird happenings with array objects before but not this one in particular.
    The strangest by far was when two array object swapped values somehow haha.

    Also I believe the array sometimes isn't written to "fast enough" and the program can continue on down the line before the write to events are finished. I'm not 100% on that one but I think I've seen some people mention it before here.

  3. #3
    Clicker Multimedia Fusion 2
    Fusion 2.5 (Steam)

    Join Date
    Feb 2017
    Location
    Switzerland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh well, it's not really reassuring that such a basic object is glitched. I hope I won't experience any of this in a finished game!

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    I woudln't say it's glitched,
    it's a basic feature of the object, when you change the position of the index (writing a value, setting index position)
    the index position will ... change

    but yeah something like loading a file is a disk operation and could be not fast enough
    if you need to perform something dependent on that data loaded it's better wating a bit (some frames is enough, if it's not humungous ) to be sure

    For indices I do exactly the same as you, by using values, this gives a greater "control" but overall depends on what you need to do

    Other than that, array object is very solid, I've never encountered "consistency" issues, I think you can trust them quite enough!

  5. #5
    Clicker Multimedia Fusion 2
    Fusion 2.5 (Steam)

    Join Date
    Feb 2017
    Location
    Switzerland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The thing is that I wasn't writing to the array nor setting the index position to anything. The mere fact of storing a coordinate "index +something" somewhere else and/or reading a position in the array in a condition ("string at index x+something") made the index change. I think it's a strange feature that the index changes then, isn't it? I'm not sure, but I don't think it happens with number arrays somehow.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    sorry, I misread your first post, you're totally right, just reading shouldn't change index position, I thought you were writing

    would be interesting reproducing the issue, I've just tried and been unable to,
    if you are able to reproduce it in some test mfa perhaps we can exclude there's something odd happening in your project

    but of course if you've solved and there's no interest in investigating more feel free to dismiss this

Similar Threads

  1. non-existing array indexes causes crash
    By schrodinger in forum Fusion 2.5
    Replies: 1
    Last Post: 10th January 2015, 07:02 PM
  2. Loading an object from array when needed (loading an array in chunks)
    By fishrod in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th March 2014, 07:01 PM
  3. Dynamic Array - Sort 2 dimension array by Column 1
    By Ryan in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 16th December 2012, 05:54 AM
  4. EXC_BAD_ACCESS when accessing global Array after a frame change
    By smart_fr in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 5th May 2012, 07:19 AM
  5. Can you change the size of an array during runtime
    By Iwantmyrpg in forum Multimedia Fusion 2 - Technical Support
    Replies: 14
    Last Post: 3rd February 2009, 04:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •