Reading a Saved File's Switch ID / Variable ID's value

Discussion in 'Learning Javascript' started by Milena, Dec 26, 2015.

  1. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    I would like to know how can I read a certain saved file's switches and variables' value. For example, I changed the value of variable 1 to 90. After that, I saved it. On the title screen, I am trying to read that saved file's variables or switches and store it to a value in Game System or Game Temp for example.

    My question is, how can I read a certain saved file's specific variable ID / switch ID and store it into another created variable?

    Thanks in advance.
     
    #1
  2. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    855
    First Language:
    German
    var data = JsonEx.parse(StorageManager.load(savefileId));
    // data.switches -> switches


    // data.variables -> variables

    Afterwards, do with it whatever you want.
     
    Last edited by a moderator: Dec 26, 2015
    #2
    Milena likes this.
  3. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    Yay, thanks, this helped a lot. All I have to do is to loop it to check each and every value to see which switch is turned on :D
     
    #3
  4. Liquidize

    Liquidize Caffeine Overload Developer

    Messages:
    466
    Likes Received:
    454
    Location:
    Somewhere.
    First Language:
    English
    Primarily Uses:
    RMMV
    If you are looking for a specific switch, and know its ID you can just do

    data.switches.value(IDHERE);
    To get the value.
     
    #4
  5. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    Okay here's a problem. What if I want to check a certain switch on ALL existing saved files? How can I do that? Because it throws me an unexpected end of input when a saved file is not existent. So my problem is, how can I check ALL existing saved file's specific switch ID?
     
    #5
  6. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    855
    First Language:
    German
    Code:
    DataManager.loadGlobalInfo();
    This gives you an array containing the header (what you can see in the save/load screen) of all existing savefiles.
     
    #6
  7. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    I see. What is the proper check for this?

    Parsing the JSON depends on which index my commands are placed. For example, command1 is switch 1. However, I want to load all existing saved files and load to see if switch value is on.

    Will I have to store thisĀ 

    DataManager.loadGlobalInfo()on a new array? If so, how can I completely loop it to check them individually if such switch is on?

    Any help on this is appreciated.
     
    Last edited by a moderator: Dec 29, 2015
    #7

Share This Page