I was looking through this post and I’m just trying to get a few things straight.
In order to use this, I can set up a Corona project that just has this code:
AppSettings = {}
AppSettings.Benchmark = “Brent”
AppSettings.Units = “Metric”
AppSettings.Code = “BZ”
saveTable(AppSettings, “AppSettings.json”)
in order to create my JSON file, since I can’t just create one in the same directory as my main.lua?
I tried just writing a JSON file and adding it to my project directory, but reading further through the blog comments I don’t think that will work.
Also, I am getting some errors when I try and run this project.
File: …ers/seandzafovic/Desktop/Volume App 2/data_entry.lua
Line: 50
Attempt to index global ‘AppSettings’ (a nil value)
stack traceback:
[C]: ?
…ers/seandzafovic/Desktop/Volume App 2/data_entry.lua:50: in function <…ers/seandzafovic/Desktop/Volume App 2/data_entry.lua:46>
?: in function ‘dispatchEvent’
?: in function ‘gotoScene’
/Users/seandzafovic/Desktop/Volume App 2/main.lua:54: in function ‘gotoScene1’
/Users/seandzafovic/Desktop/Volume App 2/main.lua:69: in main chunk
I have AppSettings={} as a global variable and then these lines of code:
--load default settings
AppSettings = loadTable (“AppSettings.json”)
OilType=AppSettings.Benchmark
Units=AppSettings.Units
OilCode=AppSettings.Code
at the top of my scene:createScene function.
I am assuming that I’m getting the error because I currently have the JSON file in the same place as main.lua. If not maybe you can point me down the right road before I waste too much more time.