Saving Attributes vs Saving Tables

TomCoffeeTomCoffee Member, PRO Posts: 175
Been using GameSalad for little apps for years but now I'm working on a real "game" for the first time. I have about 10 player values that need to be changed and saved after each round of my game is finished. Which is better for this: saving attributes or saving tables?

Saving tables seems to be "easier" because as the table values change in the round I can just save them all at the end each round with a SAVE TABLE behavior and be done with it. Referencing values from tables is also pretty easy.

Saving each and every attribute (and then loading them again separately if needed) seems to be a bit of a headache.

Is there a performance difference between the two methods? I do realize that in some cases I'll have to first load a table value into an attribute to use or change it sometimes, but that isn't a big deal.

How do you professional game makers handle saving data in your games? Thanks for any guidance!

-Tom

Comments

  • WbokoWboko Tennessee, USAMember, PRO Posts: 621
    Tables are clean, but I find myself still using good old attributes alot. My rule is for level setting and game settings go with tables for a easy clean way, but for quick game play use attributes. Also, when ever possible don not unlock your actors or you will find yourself in more fun then you want.... good luck!
  • ClockClock Member Posts: 308
    i use both. same result
  • WbokoWboko Tennessee, USAMember, PRO Posts: 621
    edited February 2014
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here are some reasons to use attributes vs. tables:

    Attributes
    Easy to work with, no need for long-winded tableCellValue() expressions
    Easy to label (not just a row/column intersection but rather a specific name)

    Tables
    Easy to save (a single behavior for tens, hundreds, thousands of attributes)
    Auto-load at runtime
    Ability to copy a full table into a master table and then copy it back to reset the game
    "Nightly" build functions such as Loop over Table and tableSearch() are extremely powerful for accessing data in repetitive or quick ways
    Easy to pre-fill with large amounts of data values due to CSV import/export features
    Ability to change "levels" by increasing the row number and keeping the code the same
    Easy to code randomized selections for more than just integers
    Ability to sort data using loops


    Also, as a side note the Nightly build available to Pro members includes the ability to enter table expressions on either side of a Rule condition so there is no longer the need to first store table values in attributes.

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

  • ArmellineArmelline Member, PRO Posts: 5,370
    I've been working on a table-less Tetris just for fun, and I can tell you now... it really depends on what you're doing with them.

    I have had to use about 40 extra rules that could have been entirely avoided if I put 20 attributes into a table.

    I'm having to do a ton of "If attribute is 1 then" "If attribute is 2 then" etc. when if I stuck them in a table it would just be one change attribute with a table cell value.

    In other words, if a table will reduce the load of your logic and the number of rules you need, go with tables. If not, stick with whatever makes you happier. :D
  • TomCoffeeTomCoffee Member, PRO Posts: 175
    Cool, thanks for the response everyone!

    This is a simple puzzle game and I like tables so... During the game I'll most likely keep values in Attributes and then when a level ends I'll write those attribute values into a table and save the sable.

    I'm a little curious about what happens when someone leaves the game in mid-level... Will have to experiment.. I've noticed if a GameSalad app is "off" for a while it seems to reset (or restart) on its own when I eventually go back to it. Not sure if that's a function of GameSalad or the hardware (do most of my testing on iOS)...

    Thanks!

    -Tom
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You'll want to save your attributes (or tables) frequently, depending on the type of app. In some cases, that means every second... in some, every time you pass a level or pause the game, etc.

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

Sign In or Register to comment.