User Tag List

Results 1 to 6 of 6

Thread: What's wrong with my write/read array code?

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Feb 2015
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's wrong with my write/read array code?

    Trying to write the first 50 of my Global Values into an array, and then read from the array later on.

    Currently have each loop activated by button press for testing.

    writeload.png

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,397
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Firstly, you only need a 1-dimensional array, so use the action/expression that just takes an X position (not X and Y).
    Secondly, global values are 1-based, so you need to add 1 to the global value index as well as the loop index.

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,397
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    And obviously you need to set the array type as "Number array" (not "Text array" which is the default) with a "Base 1 index".

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Feb 2015
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MuddyMole View Post
    And obviously you need to set the array type as "Number array" (not "Text array" which is the default) with a "Base 1 index".
    Oh blech, the codes perfect but yeah I didn't set it from Text to Number. I SWEAR I did but I guess not lmao.

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,582
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Just as MuddyMole said.

    Though I'll add that it's ok to use the [X & Y] action that you're using (and it might be a good idea if you're likely to store more types of data in this array later). But the main thing is to iterate just 1 dimension in the loop, not both. To easily understand why, it'll help to think of your array as a spreadsheet (which it kind of is). By doing:
    Code:
    Write..... to (Loopindex("write global values") + 1, LoopLoopindex("write global values") + 1)
    your current one stores the information like this, which I'm sure you'll agree would be a weird way to use a spreadsheet:





    If you instead use
    Code:
    Write..... to (1, LoopLoopindex("write global values") + 1)
    it'll store the data like this:



    This will make the array take up less space and be faster. It'll also be more straightforward to add more types of data down the track - just replace the bold 1 above with a different number to save data to a different column:

    Code:
    Write [some other data]..... to (2, LoopLoopindex("write global values") + 1)

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Feb 2015
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you as always for the in-depth explanation Volnaiskra

Similar Threads

  1. Best way to read/write between HTML5 app and database?
    By ratty in forum HTML5 Export Module 2.5
    Replies: 8
    Last Post: 17th January 2017, 03:42 PM
  2. read/write an ini
    By arthurh in forum Android Export Module Version 2.0
    Replies: 9
    Last Post: 28th May 2013, 08:08 AM
  3. How to read/write to an HTM file from an applet
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 18th November 2009, 11:41 PM
  4. Write and read 2 values at a time from array.
    By Popcorn in forum File Archive
    Replies: 0
    Last Post: 1st April 2008, 01:09 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
  •