User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21

Thread: Negative index unsupported in array - update or workaround?

  1. #1
    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)

    Negative index unsupported in array - update or workaround?

    From testing and previous searching in the forum, it seems that negative indexes are unsupported in CTF Array.
    Is this planned to change in the near future, with future versions of Fusion?

    I had to use additional Z dimensions to make a workaround , but this makes the code much slower and has a lot of overcoding in it.... any better solution?

    Thanks for sharing your views and informations.

  2. #2
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,197
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Why are you trying to use negative indices? Negative indices are unsupported in most types of arrays. Indices are typically from 0 - (Size of dimension - 1) 0-based or 1 - (Size of dimension) (1-based)​.


    I do not see this being changed in future builds of MMFusion simply because it is not typical with standard programming. Even the 1-based option offered by MMFusion causes quite a bit of hassle.

  3. #3
    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)
    Reason is I'm storing data using the array indices just like X-Y coordinates of a map for instant and easily referrable data retrieval,
    but since this coordinates can go below zero because the map casn extend in every direction, i need also -X and -Y to cover all the possible areas.
    I managed to do that with three additional Z indices (one for -x+y, one for -x-y, one for +x-y)
    but that made the code much more *inelegant* and slower

    I could have done that easily with databases, but unfortunately that proved to be even slower.

  4. #4
    Clickteam Clickteam
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,645
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    It's not supported, but is simple to work around… if you need a range of -100 to +100, simply set the dimensions to 200 and then add 100 to your own references (so -100 becomes 0).

  5. #5
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or use "Named Variable Object"

  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)
    Quote Originally Posted by Simon View Post
    It's not supported, but is simple to work around… if you need a range of -100 to +100, simply set the dimensions to 200 and then add 100 to your own references (so -100 becomes 0).
    Thank you for the suggestion,
    unfortunately I have no appliable range, since this map could expand virtually to an infinite size,
    thus the need for negative indexes to cover this "freedom" of coordinates over all the directions
    (otherwise the map could -yes- expand infinitely, but only to the right-bottom,
    and have a forced limit in the upper left corner on its x0 y0 origin).

    For this application the negative index would have been the perfect solution,
    and since I have absolutely no idea of what's going on "behind the scenes" in the code governing the Array object,
    I was wondering wether a negative index would have been difficult to implement or simply a fact of adding/addressing some values...
    Obviously, since it never came out as a request before, I already see how its usefulness among user should be not-so-high...

  7. #7
    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)
    Quote Originally Posted by Sphax View Post
    Or use "Named Variable Object"
    OH MAN!
    I didn't ever notice this extension.... just checked the description and seems to fit perfectly my needs.

    Is its speed on-par with standard array object?
    My application loads and/or saves the values with fastloops about 50/100 times a second.

    I'll soon try to implement and report back.
    Meanwhile, thank you!

  8. #8
    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)
    (just for completeness: I ask about speed because I already tried a similar approach with INIs and they weren't fast enough, there was a noticeable lag when writing/loading all that values-.. the array was the choice over SQL and INIs due to its speed, since It did de job without slowing down the game experience)

  9. #9
    Clickteam Clickteam
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,645
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Hmm… if you need that level of limitless expandability in all directions, I suppose my suggestion would be 4 arrays, one to represent each quadrant. You would have to remap the coordinates slightly to make them work as one.

    The 4 arrays could easily be copied into a single array for saving (using the z index for this woukd be simplest). For that matter you could use the z-index for each quadrant, although this could potentially be less efficient in memory at runtime than 4 separate 2D arrays would.

  10. #10
    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)
    Yes, that was one of the solution I thought of, but before trying the four-arrays I went for the z-index solution, because it seemed easier to save and load,
    one simple index to represent the four quadrants, but that experiment ended up with noticeable lag when doing all the calculations needed to evaluate the correct Z index to use at each single coordinate

    Now trying the Named Variable Object... I'll report back!

Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Dynamic Array index base?
    By gastrop0d in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 20th December 2011, 08:49 AM
  2. Removing an index from an array
    By Jason in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 16th November 2010, 09:27 AM
  3. ignoring array index values before the current one
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 24th February 2009, 10:02 PM
  4. fast loop & array index
    By delusan in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 19th October 2007, 06:37 PM
  5. Dynamic Array- find row index?
    By crugh in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th May 2007, 05:21 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
  •