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
You need to execute the save table behavior once you alter any table data you wanted saved.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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
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?
dapion.de
[https://twitter.com/dapionde?]
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
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.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I mean with immediately this one...
dapion.de
[https://twitter.com/dapionde?]
Yep as I said I tried that and it didn't work on restart
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"
post a screenshot of your rule(s) or make a .zip
dapion.de
[https://twitter.com/dapionde?]
It's basically identical to your picture
So this rule works fine for me...
dapion.de
[https://twitter.com/dapionde?]
Yeah man that's why I'm asking on the forums....
@Armelline
Any ideas?
I'm going to bed now I'll check out replies and try to fix it some more in the morning
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.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Tables will default back once you quit preview in creator
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Yeah I've tried it on Windows Creator, Mac Creator, GS Viewer and Ad Hoc
works for me. Here is a simple test project. make sure you are doing all booleans.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support