What's better? Tables or attributes
YeezyHypeBeast
Member Posts: 60
I have a pretty big game that I'm about to start coding once the art is finished. There is going to be a lot of data in the game and I want to have it using the most efficient way. So far:
tables:
I have no clue how to use them.
Attributes:
I know how to use them.
It seems like my code would start getting messy with so many.
Easy.
Which should I use? Can someone give me some knowledge of table? Thanks
Comments
Tables. Easy. Tables are essentially attributes listed in row/column format. With tables you can dynamically write or call to a specific cell, search for a specific term or variable, and much more. It's much more efficient too. There are dozens of videos on tables on YouTube. I'd recommend searching up GameSalad Table Tutorials and several should pop up.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
What @Braydon_SFX says, tables all the way.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Tables are very easy to use once you get the hang of them. I have a tutorial below for creating checkpoints using tables. It's not a table tutorial specifically but its a pretty simple introduction to tables if you're interested.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I'm going to buck the trend here.
If you have lots of information to store, tables is probably the way to go. They make managing lots of data easier. Tables are also best for things like level complete status, or recording how many stars per level.
If you have only a handful of bits of information to store, perhaps less than 20, and particularly if they're disparate, use attributes. I'll never put music on/off status or things like that in a table, unless I have to make a table anyway.
Tables use more overhead than attributes, and are more difficult to reference individual, static ones. Attributes can have values constrained to them, tables can not (properly). Overall, attributes are less flexible, though.
In reality, you'll need a hefty mix of both. Each have a place, but people often recommend tables for tasks attributes would be better for. Let's look at two examples:
I'm building a database of levels. For each level, I want to record the fastest time it has been completed in, the number of stars earned, and if they found the secret bonus. I have 100 levels. Managing this in attributes would be a complete nightmare. It would be impractical to say the least. Tables are the obvious choice here.
I've made a game and need to store the following bits of information: The game mode selected, the name of the player, the costume he's chosen for the character, the current enemy difficult (which increments by a random amount each level), if music is on/off, if sound fx are on/off. A lot of people would just make a table to store this, but that would actually be more demanding on the game and more difficult to reference each one (you're having to use the Change Table Value behaviour each time you change one, for one thing). I'd recommend Attributes as the best option here.
A lot of people default to tables for everything, but I've always found that a bit silly. Attributes have a very valuable place. Tables shouldn't be the go-to, they should be what's used when attributes aren't sufficient - either due to number, or the need to dynamically reference them.
You'll almost certainly be best served by a mix of attributes and tables.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline .....you little rebel. :P
But I agree.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@Braydon_SFX @Armelline @jamie_c @Hopscotch Okay. Thanks guys
Just keep in mind that writing TableCellValue(game.table name, 1, 2) or TableCellValue(game.table name, 3, TableColNumber(game.table name, "health")) throughout your code can get tedious
@KevinCross okay thanks for the tip
Generally I use attributes which store information which is only needed in the current session of play. Any information which is required next time the game is played I store in a table, things like high scores, etc.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Nice, I like that guideline. Simple and helpful.