Tables--are their values saved?

When the game quits, are the current values in the table saved and automatically retrieved when the game starts? I want to save data this way instead of saving a value to a key.

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    You'll need to use the Save Table behavior for the table to save its content. It will automatically load the data.
  • TapcodiaTapcodia Member Posts: 84
    So it would be wise to save the table after every update then? Will that cause a performance issue if done too often?
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    edited December 2013
    I don't know if I would do it every table update, especially if your game is heavily relied on tables... Maybe every scene change or major event.
  • tahakitantahakitan Member Posts: 102
    no it should not have an issues unless you are saving multiple tables every .1 seconds. Even then you have to really overkill it. but it depends on the persons game at the end. I did an endless runner game where I saved into a table the highscore every .1 seconds and it didn't cause any performance issues.
  • TapcodiaTapcodia Member Posts: 84
    Mine would be like maybe 2 or 3 rows out of 10, 1 column every 5 seconds in one table, and thats maximum. Sounds like i will have no issues. Thanks!
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    I don't think I'm saving mine, and yet they seemed to be saved. Freaky >.<
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Table data persists as long as the game is not shut down and restarted when the table is not saved. (Just like game attributes)
    As said above, tables saved via the Save Table behavior, will automatically be loaded when the app is shut down and restarted. Though it is lost when the app is deleted and then reinstalled.
    HOWEVER, when you save a table, any updates to the table between app versions will not update and override the saved table unless the app is uninstalled(thus losing all saved data) and reinstalling. Or you add in logic to update the table. (Except columns because new columns can't be added or removed.) So plan ahead.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited December 2013
    HOWEVER, when you save a table, any updates to the table between app versions will not update and override the saved table unless the app is uninstalled(thus losing all saved data) and reinstalling.
    Could you please clarify this bit? Sorry but I don't understand what you're saying.

    EDIT: Scrap that, you mean changes to the table structure. I thought you meant changes to the data.
  • artfishartfish Member, PRO Posts: 369
    I would save the table as often as possible. Example, In my game, you collect an item. It's added to the inventory table. Table does not get saved. Player gets a phone call. Player comes back to game. Item is now missing from inventory and player cannot progress. What did I learn? If the save table is in complex group of rules/behaviors that fires when touch is released, and it's one of the last behaviors to fire in that group, it doesn't always save. Save that table often and save it again.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    HOWEVER, when you save a table, any updates to the table between app versions will not update and override the saved table unless the app is uninstalled(thus losing all saved data) and reinstalling.
    Could you please clarify this bit? Sorry but I don't understand what you're saying.

    EDIT: Scrap that, you mean changes to the table structure. I thought you meant changes to the data.
    I also mean to the table data too. So say you have an actor that gets its size values from a table. The table holds the values for 1024x768. You also used that same table to save high score values, but in a different column. In your next iteration of the game, you decided to change the actor's size value to 800x600 in the table. The change won't take effect in the next version because you have used the Save Table behavior and the original values are also saved. Instead of adding logic to update those values and resave the table, it is better to make sure you separate tables into things that will get saved and those which are data and can only be modified by the developer.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    @CodeMonkey I added 30 blank rows to my stats table for the future thinking that if I could think of other things to track I could add them without any problem, but what you're saying is that I can't and that those 30 rows are now useless? Not actually worried about 30 blank rows, as I guess I can start a stats2 table instead. I just want to make sure I understand correctly before I cock it up later on.

    It turns out I was actually saving the table in several places so that would explain why the data is available each time the app is properly closed and re-opened.
  • natzuurnatzuur Member Posts: 304
    edited December 2013
    You could just add logic in an update to the app to update the already saved table via changing the table value during run time and saving, thus changing the saved table with the new info, rather than hard coding the info into the table and losing it to the saved table right?

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    You could just add logic in an update to the app to update the already saved table via changing the table value during run time and saving, thus changing the saved table with the new info, rather than hard coding the info into the table and losing it to the saved table right?

    Sounds reasonable. Having a rule to only update the row and columns if they're currently blank. Thanks

Sign In or Register to comment.