Exporting to XCode with saved data

Hi! I’m currently working on a new game using Codea. In the past, I’ve often been using “lua” files to write my levels in the game textually. This way, when I would export the project to Xcode, the levels would be included with the exported package.

The game I’m currently working one being more complex, I decided to create a level editor which I would like to use to create the actual levels for the game. The editor saves and loads the created levels using saveProjectData/readProjectData. However, the created files don’t seem to be exported with the project. I know I could probably plug-in my device to a PC, grab the files and then add them to the Xcode project, but that’s not a good solution for me since my build process is automated (CodeaProjectBuilder).

Is there a way to save dictionary-based data that gets exported with the project?

I guess could use saveProjectTab and readProjectTab, but I would like to avoid having these extra lua files in my project. Also, when using saveProjectTab, does the actual tab gets “recompiled” right away, or do you have to restart the project?

Thanks!

Well to answer one of my questions, saveProjectTab is not “recompiled/parsed” until the next time you launch the project.

@jfperusse, I ran into the same problem. I had switched from saveProjectTab to saveProjectData because I need to be able to save multiple levels without restarting the app, only to export and find all the levels gone.

@JakAttak, I currently have a solution which would also work for you. Basically, I have created new functions called “saveExportData”, “readExportData” and “clearExportData”.

Saving always saves to project data. Also, when running from Codea, it saves to an “ExportData” tab (a simple key/value table).

Reading first tries reading from project data. If not found, it will check if the exportDataArray exists, and read from there.

What’s interesting is that you can simply replace all calls to saveProjectData/readProjectData with saveExportData/readExportData and it will work (after all data is saved and the project is exported). Since the exportData is not read while running from Codea, you don’t have to “restart” the project every time.

It’s too bad though that project data does not work as expected. The documentation says “Project storage is bundled with your project. That is, sharing your project will also share the associated data.”, which I thought meant “exporting your project will also export the associated data”, but it doesn’t seem like it.

@jfperusse, nice. I had just used iExplorer to move it :stuck_out_tongue:

I remember data used to be exported with projects. I think it got lost somewhere during 2.0

Yeah, I want to avoid any additional manual steps, which is the main reason why I created the CodeaProjectBuilder :wink:

I hope @Simeon reads this and clarifies if it is an issue that came with 2.0.

Thanks!