That would be fine too.
i wouldnt hardcode level info in code but store it in a json file on disk, and load on demand.
if performance is an issue, you could store levels in batches or even separately, surely you dont need all of them available in ram.
come to think of it, sounds like SQLlite could do the job perfectly for you. Instant performance and simple storage.
Hi,
I would agree with @anaqim. Use SQLlite to bring in the data on demand.
https://docs.coronalabs.com/api/library/sqlite3/index.html
-dev
Sounds good.
But should I manually convert the files from module to sql?
And then since I have nominated it is better json or sql file?
sql will be faster and frankly, get the habit of using it as for most local info storage needs, it the better option imo.
if you can convert your data to a table, it should be simply to loop through and insert the data.
note, sql is usually a bit slower when inserting/creating new data, but for reads, it is very fast.
Hi,
You’ll want to create your database using an offline tool like http://sqlitebrowser.org/
It’s a way different approach than using json, though you could store the json string in the database record, which may give you more flexibility, but could be extra work if your json object structure changes over the course of development. You will still need some key to search against to get access to the data. A “level” id or something similar.
-dev
Thanks @anaqim and @Develephant for the immediate answers.
I do the tests right away.
Since we’re wondering if it’s best to use sql also to save app data. At the time I used json and looked good. Could I have improvements to use sql even in this case?
Hi,
As a general recommendation I would always go with a database for any data needs beyond a few objects.
-dev
I understand thank you very much.
Feel I’m trying to use db but I never used sql with lua. Could you give me a straight?
I need to do a loop to store a db with the table levels and how it is…
local levels = { --1 { graphics = { name = "graphics", { kind = "RoundedRect", x = 160, y = 0, height = 520, }, }, physical = { name = "physical", { kind = "Chain", chain = { 140,260, 180,260, 180,-260, 140,-260 }, connectFirstAndLastChainVertex = true }, }, elements = { { name = "finishPortal", x = 160, y = -240, radius = 30 }, }, }, }
then I have to be able to read the db and put it in a lua variable? is this right or is it not better to put the db in a variable?
As dev mentions, using the sqlitebrowser comes very handy.
Regarding json vs sql, well, it probably wont matter in your case here but json files have to be decoded, sql replies not.
sql lookups (select) is also blazingly fast, and you can get it sorted and filtered before you receive the data.
With json, you’ll have to sort and filter it yourself.
If you are more confortable using json and storing files in that way, i suggest you make your test and check if it works for you, if sqlite is more unknown territory. It is absolutely nothing wrong in that approach as there are always more then one road to rome. Mind you, I dont know that much about sql databases but got sqlite3 up and running pretty fast.
For my current project im using mysql in the cloud, made easily accessible by the great coronium core api, which develephant just released. Cant praise it enough, really!
How to loop through your data and store in a database or json file is something you know better how to do, just focus on learning the storage types first.
Oh, becuase the sql is so fastg, you dont need to load it into a table before using it, just load on demand exactly the part you need at any given time.
Hope this helps
anaqim
Thanks very useful.
I know better use json but if sql is better always better to upgrade. I apologize for the play of words.
Only one last question.
If i understand with sql I can create one file with all levels? or is it always better to make a file for each level?
No worries mate, I am by comparison to most people in here, just an amateur.
Like to help if/where i can, even if my posts sometimes get overruled by those much more proficient 
Yes the SQL is a single database file in which you create tables, or in your case probably a single table, that will keep all your levels stored.
Later you just ask the database to transfer level data back to your app with a select statement (look up SQLite3 on the internet), which means you only load the data you need at any given time.
Or you could use this link https://www.tutorialspoint.com/sqlite/
Cheers!
Very kind.
I immediately go to the test 
dont forget coronas own sqlite3 documentation 
Certainly he tried to analyze the various guides 
Despite the attempts I can not put the FOREIGN KEY in the tables, sqlLite allowed it?
you mean the normally set auto increment key? yes it should work.
in general it is good practice to have a single field in each table with an auto key, just to make sure each row is unique.
you dont add anything to it, just let it auto increase by itself.
if you use dbbrowser then when you add the first field, name it “key” or “id” (i prefer key), choose INTEGER and check PK (primary key) and AI (auto increment).
thereafter you continue to create the fields you want.
hope it helps 
Thank you but in fact it is not what I was looking for…
After other searches, however, I found it
I share it if it can be useful to you too 
Anyway for this time I think I used json.
I’m trying sql and it’s very nice however implementing all those tables below into a database would take a long time.
{ graphics = { name = "graphics", { kind = "RoundedRect", x = 160, y = 180, height = 160, }, }, physical = { name = "physical", { kind = "Chain", chain = { 140,-740, 140,-500, 380,-500, 380,-380, 140,-380 }, connectFirstAndLastChainVertex = true }, { kind = "Rect", x = 540, y = 40, height = 240, }, }, elements = { { name = "finishPortal", x = 700, y = -780, radius = 30 }, { name = "aswa", x = 200, y = 110, directPaths = {{x=200,y=-360}, {x=200,y=110}}, paramsPaths = {useDelta=false, constantTime=2200, loop = true} }, }, },
this is the table of a simple level and as you can see there are many nested tables …
I should also retouch the code in the various modules
oh i see, keys between tables.
whatever works and makes you happy man 