Saving options with tables?

Hey guys,
I know this is supposed to be really simple but I'm having difficulties saving 3 boolean attributes into a table and then loaded when the game is opened.

I have 3 boolean options. When one is changed in the options scene, I change the attribute with a "Change Attribute" (e.g. set game.option1 to false) and then I also have a "Change Table Value" where I change the value in the correct table, row & column to that attribute (i.e. game.option1).

I do this for each option for when they are toggled.

On the main scene (the first one when the game is opened), I have a 3 "Change Attribute" rules that set game.option1, 2 and 3 to tableCellValue(game.table, x, y) to their respective option.

I have no idea if I am doing any of this right (I assume I'm not even close because when I try testing it, the options don't save when I restart the game with the little circle arrow thing in the preview)

Hopefully someone can help me here.

Thanks!

Daniel

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    You need to execute the save table behavior once you alter any table data you wanted saved.

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @Lost_Oasis_Games said:
    You need to execute the save table behavior once you alter any table data you wanted saved.

    Sorry, I forgot to mention I do have a Save Table behaviour on the back button to return from the options scene. It's the only way to leave that scene so it does save the values to the table. I think the issue is with the loading them on restart but I'm not 100% sure

  • dapiondapion Member, PRO Posts: 353

    First...why do you not save your table after you change the table?
    In my projects I do it immediately.

    Do you test the Table in Creator Preview?

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @dapion said:
    First...why do you not save your table after you change the table?
    In my projects I do it immediately.

    Do you test the Table in Creator Preview?

    I do save the table after. If you mean immediately after the "Change Table Value" behaviour, I tried saving the table after that but that didn't work either.

    Not entirely sure what you mean by "test the table" but I have tested to see if the values get saved on restart (they don't) and if the table stores the right value (it does).

    Daniel

  • ArmellineArmelline Member, PRO Posts: 5,421

    Tables are loaded automatically so the problem will either be in the saving of the table or in the logic you're being used to check the booleans you're storing in the table.

  • dapiondapion Member, PRO Posts: 353

    I mean with immediately this one...

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @dapion said:
    I mean with immediately this one...

    Yep as I said I tried that and it didn't work on restart

  • Daniel543MDaniel543M Member, PRO Posts: 47
    edited September 2015

    @Armelline said:
    Tables are loaded automatically so the problem will either be in the saving of the table or in the logic you're being used to check the booleans you're storing in the table.

    I tested to see if the tables had saved the right values when I went back to the initial scene so I added an actor with a Display Text behaviour to display each of the values of each option.

    When the app starts, they are correct (all true). I go to the options scene and change option1 and option2 and then go back to the initial scene. It correctly displays the text "false true false". I press the 'reset' button at the top of the creator preview screen and then it all changes back to true even though it's supposed to remain "false true false"

  • dapiondapion Member, PRO Posts: 353

    post a screenshot of your rule(s) or make a .zip

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @dapion said:
    post a screenshot of your rule(s) or make a .zip

    It's basically identical to your picture

  • dapiondapion Member, PRO Posts: 353

    So this rule works fine for me...

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @dapion said:
    So this rule works fine for me...

    Yeah man that's why I'm asking on the forums....

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @Armelline
    Any ideas?

    I'm going to bed now I'll check out replies and try to fix it some more in the morning

  • ArmellineArmelline Member, PRO Posts: 5,421

    We really need to see your rules or project. Sounds like you're either not saving properly or are overwriting the table with the default values after the save has occurred.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Tables will default back once you quit preview in creator

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @Armelline said:
    We really need to see your rules or project. Sounds like you're either not saving properly or are overwriting the table with the default values after the save has occurred.

    @Lost_Oasis_Games said:
    Tables will default back once you quit preview in creator

    I don't quit the preview, I press the reset arrow to simulate opening and reopening the app.

    When I press the reset button, neither the game atrributes (option1, option2 & option3) or the table values of these options get loaded correctly. It sets them back to default.

    Also, a separate question; does the iAP PurchaseTable save automatically? Because I can't select it in the Save Table dropdown.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    did you try it in the viewer. This might be a Windows creator issue. Your code looks right.

    No you don't have to save an IAP table that is handled by the server.

  • Daniel543MDaniel543M Member, PRO Posts: 47

    @Lost_Oasis_Games said:
    did you try it in the viewer. This might be a Windows creator issue. Your code looks right.

    No you don't have to save an IAP table that is handled by the server.

    Yeah I've tried it on Windows Creator, Mac Creator, GS Viewer and Ad Hoc

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    works for me. Here is a simple test project. make sure you are doing all booleans.

  • ArmellineArmelline Member, PRO Posts: 5,421
    edited September 2015

    Try putting the save table behaviour in an "after 0.05s" timer.

    The IAP table never gets saved. It gets filled with info from Apple each time you want to use it with a "Request Purchase Data" behaviour.

Sign In or Register to comment.