Hi All,
I’m trying to use JSON to save and load the levels settings table in myData.lua file
I try to save the table every time I update it when the level is completed
And to load the table when I create the level selection scene.
I copy to my main directory the file loadsave.lua from the tutorial: Saving and Loading Lua Tables with JSON.
I added to all the relevant files the line local loadsave = require( “loadsave” )
levelDate is the name of the lua file that holds table M
To save the table I use the below line:
levelData.M.settings = loadsave.loadTable( “settings.json”, system.DocumentsDirectory )
I also tried to use it like this levelData.M.settings = loadsave.loadTable( “settings.json” )
To load the table I use the below line:
loadsave.saveTable( levelData.M.settings, “settings.json”, system.DocumentsDirectory )
When running the simulator I receive the below error:
“attempt to index field ‘M’ (a nil value)”
What am I missing?
Regards,
Guy
