Text assets

Hi!

I bought Codea the other day with the intention of pootling around with it on my iPad Pro in the evenings and I’m a little unclear on a couple things. I want to do an interactive fiction text game for funsies and I don’t want to commingle assets with code. So, my initial plan was to do the various text chunks as separate asset files and then load them as needed from the app’s local storage, but I don’t see any sort of plain text editor functionality in Codea.

I see references to using Dropbox and stuff like that, but I’m not sure how that’s supposed to work with an XCode export. What is the conventionally accepted way to work on text assets separately from code?

Have you looked at saveText under Storage in the built in documentation.

I did, but as I stated, I don’t want to commingle assets with code. That means I want to create those text assets independently of Codea itself and then import them to local project storage, or by using some sort of internal plaintext editor that lets me save text assets for a project.

The documentation for saveText implies that I’d have to stub the text content into a Lua file as a variable, and with a saveText call, and then run it every time I wanted to add a new text asset, which seems a bit…clunky.

Let me see if I understand what you’re trying to do. You want to create some kind of text file, say on a PC, save that to a file or something and then read it into the project storage in Codea. Would this be a one time shot or would you keep updating this on a PC and sending it to Codea again. I’m a little hazy on what you want to do.

You could always use the Codea editor to key in whatever text you want and save it like a Codea project. You could save each section of text as a tab in a fake project. Then you could use readProjectTab to read any tab you want to get access to the text.

The ideal setup for me would be to create those text files in a text editor built into Codea (similar principle to how Panic’s Coda app for websites has a built in text editor) that lets me save them to the project’s asset location. Failing that, I’d like to be able to import text assets from external sources like Dropbox or some other text editor on my iPad and save them to the project’s asset location. That way, when I’m in author mode, I just type story chunks and save them, then later, when I put on my coding hat, I’m just loading them at runtime into the game.

Oh, I missed your 5:30PM comment. Would those tabs be all mixed up with the code tabs? Or am I able to access tabs from different projects?

You can access tabs from any project. You can create a project called text and have different tabs within it. From another project, you could read any tab that you want from that project.

Aha! That might just work! I’ll test that out tonight. Thanks!

That didn’t really work for my purposes.

How come there isn’t a UI button for the asset picker? I managed to accidentally discover that I could add and edit plaintext files in Codea, but the only way to summon the asset picker is by tapping on a parameter for one of the load/save functions. This…offends my sense of order. There really ought to be a button in the UI that can be tapped to open, browse, and edit project assets. Is there any way this could be added?

@misanthrope See the function assetList. You give it an asset pack name as a parameter and it returns a list of all the assets in that pack. You can then load that asset (you’ll have to create your own button). You should look thru the built in documentation to see the different functions that are available to you. I can give you an example if you need it.

Just to clarify, I’m talking about the Codea UI itself, not an in-game UI, to streamline the process of authoring assets. Are you suggesting that the edit mode UI can be edited?

@misanthrope yeah there is a built in text editor and I’m ashamed to say it’s kind of hidden away in the asset picker. I want to rethink how this works and is exposed in the UI — though with iOS 11 and code sharing and resource sharing the best solution might just be to have a project that is simultaneously edited/run in Codea and have its assets edited directly from other apps (Textastic, Coda, Procreate etc)

That would be fabulous. I’m an Unity developer, so proper asset management is kind of a big deal. I wasn’t looking forward to having to roll my own tools in Codea just to manage my project assets. That’s too much like my day job, and after hours, I just want to unwind and focus on content creation and straight up game logic rather than pipeline implementation.

@misanthrope yeah I totally agree. And it also lets us focus on making a great code editor and runtime instead of coding auxiliary editors.