Hi,
Not sure if you determined whether to use the database, but with your level structure you should probably just store it in the database as JSON.
As an example with your data:
local json = require("json") local sqlite3 = require("sqlite3") local path = system.pathForFile( "game.db", system.DocumentsDirectory ) local db = sqlite3.open( path ) --============================================================================= --== SAVE LEVEL DATA --============================================================================= local level = { 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} }, }, } local lvl\_num = 1 local data = json.encode(level) --table to json local query = string.format("INSERT INTO levels VALUES (NULL, %d, '%s');", lvl\_num, data) db:exec(query) --============================================================================= --== LOAD LEVEL DATA --============================================================================= local lvl\_num = 1 local query = string.format("SELECT data FROM levels WHERE level=%d LIMIT 1;", lvl\_num) for row in db:nrows(query) do local data = json.decode(row.data) --json to table print(data.graphics.name) --graphics end db:close()
I actually just created the database using the DB Browser for SQLite tool (calling it game.db) and put it in the Corona Documents directory sandbox folder. You should be able to create the initial database structure with this query:
db:exec[[CREATE TABLE "levels" ( id INTEGER PRIMARY KEY AUTOINCREMENT, level INTEGER UNIQUE, data TEXT NOT NULL );]]
-dev

