Long story short, I have a bunch of *.txt levels for my game in the app resource folder. Since there doesn’t seem to be an easy way of loading them on the go from there, I would like to copy them all to DocumentsDirectory on the first run.
When levels are stored in the sandbox they do load fine. When they are in the project folder, however, the app doesn’t detect them (the loaded file is nil). Specifying the path to system.ResourceDirectory doesn’t help either.
I am laboring under the assumption that, since you are looking to store level data in the resource directory, you have static levels which you won’t be updating dynamically.
I think you’re making this a bit more complicated than it needs to be, insomuch as, you don’t necessarily need to code and store the level data in a different way than you are developing the other parts of your game. If you simply create another module with the name “levels.lua”, and put all of your level data here, then load it like you would any other module, I believe you would accomplish the functionality you are trying to achieve.
The important part to remember is that JSON data is just data in tables; you could just as easily have Lua tables holding all of your data and read it in as normal. If you take a look at Roland Yonaba’s Jumper lib example, you’ll see a very simple description of “level” data in a Lua table.
When levels are stored in the sandbox they do load fine. When they are in the project folder, however, the app doesn’t detect them (the loaded file is nil). Specifying the path to system.ResourceDirectory doesn’t help either.
I am laboring under the assumption that, since you are looking to store level data in the resource directory, you have static levels which you won’t be updating dynamically.
I think you’re making this a bit more complicated than it needs to be, insomuch as, you don’t necessarily need to code and store the level data in a different way than you are developing the other parts of your game. If you simply create another module with the name “levels.lua”, and put all of your level data here, then load it like you would any other module, I believe you would accomplish the functionality you are trying to achieve.
The important part to remember is that JSON data is just data in tables; you could just as easily have Lua tables holding all of your data and read it in as normal. If you take a look at Roland Yonaba’s Jumper lib example, you’ll see a very simple description of “level” data in a Lua table.
Thanks for the answer. I did just that, I just thought maybe apk installation is like a Windows installer and can put files in the specified folders. And about the finished file, it’s all my weak English. I meant the file with the settings I already have, I wanted to avoid creating it in the code, and just put it in the right folder during installation.