Saving over locally saved tables

stueynetstueynet TorontoMember Posts: 166

Here is the setup. I have a table called upgrades that stores all the upgrade items. Name, Image, Cost, and State. All of the upgrades are either true or false.

In the game, the user can buy and upgrade and then it changes the boolean State to true and saves the table. This has been working great. Here is the problem, when I go to add new upgrades to said table, on devices that have already bought upgrades, it doesn't see the new table data. On upgrades that have never purchased (and thus never locally saved the table), it works fine and the new items are sown available.

Obviously I set something up wrong here from the beginning but the problem is that now the game is in the wild and I want to add a new item for upgrade. Any thoughts on how I can get around this issue?

My Latest GS Game - Tiny Spirit
My First GS Game - Dashing Ralph

Comments

  • stueynetstueynet TorontoMember Posts: 166

    Let me clarify the issue a bit more succinctly. If I have a table of items that the user has acquired during the game, and I want to add a new item for them to possibly acquire, how can I make that happen? It seems that once the user hits save table, if I change the table in Creator, when the game loads for the user, it loads their locally saved version. So I need to add more to their locally saved version.

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    While an app is running, table data is stored temporarily. One the app quits, that table data is deleted. If you open the app again, the default table data will once again be available.

    If you use a Save Table behavior, then the table data in its current state will be saved to the device. If you quit and re-open the app again, the table data will be the same as when it was last saved.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • stueynetstueynet TorontoMember Posts: 166

    Thanks @tatiang‌ I figured as much. So the issue is that I am using the same table to save the state of the purchase of an upgrade with the other upgrade data. So now that I want to add a new upgrade to that table I have a problem. What I will have to do is create a new table just for storing the upgrade status for items and another table that I never save over which will simply house the menu of upgrades available and their various attributes.

    The issue will be pushing he next upgrade. My thinking is that I will write some logic in the beginning to check if the user has any upgrades then copy those states to a new table which I will use going forward for managing state only. The attributes of the various upgrade items will be stored in another table which I will be sire to never run a save table method on.

    Thanks again!

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

  • stueynetstueynet TorontoMember Posts: 166

    So for anybody following this thread I thought I would outline how I am going to deal with all the users who have amassed upgrades using the single table which is now saved locally on their devices.

    • Create a new table to hold just the upgrade booleans (Give it lots of rows). With this table we will map the status of an items upgrade to the same row in our menu table. This table will be SAVED every time a transaction occurs.
    • Create a new table to hold the unchangeable values (price, names etc…). The menu so to speak. This table will always load into game attributes at run time and NEVER be saved over.
    • Modify the game logic to look to the 2 new tables instead of the old merged one (because thats dumb). Current game logic pulls both information, AND status of upgrades from one table. So now we just have to reference 2 tables for various parts instead of the one. That is easy enough. So now our game will be running fine for NEW users. Now for the users that already have upgrades purchased:
    • Do a check in a new controller (compatibility controller?) to see if the old table exists and if any of the upgrades are set to true. If not move along but if so, we have to map those upgrade states to the correct row in our new upgrade state table. Thus preserving the user's purchased upgrades.
    • After this clear the old table by copying a blank table to it, and as such never running the above migration again
    • In a few months delete the compatibility logic?

    Thanks for listening. Hopefully this helps others regarding the importance of understanding tables BEFORE you release your game ;).

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    You don't need to make all those rows. You could use the add row every time a purchase is made.

  • stueynetstueynet TorontoMember Posts: 166

    The rows are not for individual transactions. They are for new purchasable items. So in my case you can buy something and it is turned on forever. The issue I had was that I wanted to add more items for sale. So now I have 2 tables:

    tbl_menu (read only)

    • Houses all the information about items

    tbl_inventory

    • Houses just rows and a boolean to indicate whether its been purchased. I just have to map the row in the menu to the row in the inventory table.

    My Latest GS Game - Tiny Spirit
    My First GS Game - Dashing Ralph

Sign In or Register to comment.