I have a file called “levels.lua” which holds all my level data. I load the data by calling require(“levels”) at the top of main.lua
I also have a file called “customlevels.lua” which is where users are allowed to save their own custom levels. In the simulator, I have customlevels.lua sitting in my root directory, and I require it just like the main levels file. This works great.
Unfortunately, now that I’m trying to run on a device, I need to have customlevels.lua output to the documents directory. I’ve got it doing that now, and I can see that the file is being created properly in the sandbox.
But I can’t call require on a file in the documents directory (Can I?) so I need to do something like the following:
(in main.lua)
local path = system.pathForFile(“customlevels.lua”,system.DocumentsDirectory)
local file = io.open(path, “r”)
if(file) then
blah…
Has anyone tried to do this? Is there something obvious I’m missing? [import]uid: 65996 topic_id: 15423 reply_id: 315423[/import]
[import]uid: 3826 topic_id: 15423 reply_id: 57017[/import]