Table VS Database
Well, just to make sure you understand, a Lua table is an object in memory… like an array, string or any other variable. SQLite DB is a physical(in a sense) file on the devices drive. The only way it would make sense to ask to use 1 or the other,in my opinion, is should you hold the data values in memory during game play or if you should just read/write to the DB every time you need those values. In that situation for performance reason holding the values in memory via a table is better.
The thing is for anything that will persist across different sessions you would want to write the table values to the DB(or some other file where you can reaccess them, such as just a text file holding a json dictionary).
Basically comes down to using Lua tables during gameplay and using the DB for saving the game data.
Modularising
Seperate lists, really. Lua tables are incredibly versatile but in cases like you are mentioning i try to format them to be similar in structure to a SQL db table, meaning kind of fixed fields that line up great. I’m assuming with all of the things you want to track that your Blade of Carnage weapon isn’t going to use the same data fields/types as your Cheese of Healing item. Also, there will be plenty of times where you may want to iterate over just your weapons. If everything is lumped together you would need to iterate over it all which is wasted processing power.
I hope that makes sense.
Also, you could also do tables of tables, so you have master table with subtables of your items but probably isn’t much benefit for you(ie masterTable.weapons[0].damage vs weapons[0].damage).
[import]uid: 147305 topic_id: 30719 reply_id: 123049[/import]