Having done a bit more testing, it seems that readText
only works for files with the extension .txt, it can’t see, or load, for instance, a text file with extension .lua, or .lua.txt.
If you add two extensions, eg “MyFile.lua.txt”, at first that seems to work: you can see and select the file in the asset picker, and you can edit it by pressing the little pencil icon (a really nice feature, btw, for making quick edits to text assets). Unfortunately however, readText
fails to read files with two extensions, it just returns nil. It has to be “MyFile.txt” to work properly. This is a shame I think. The two extensions trick would be an easy way of including all sorts of text-based assets.
This is a problem for working with 3D files, as although they’re basically text files, you’d want to know whether it was .obj, .ply, .mtl etc. I guess you could get round it with a prefix or suffix, eg “OBJ_myModel.txt”, “myModel_OBJ.txt” etc
What do people think? It would be very handy to be able to select 3D models in the asset picker, if they were saved in this way (you’d only be able to see the model name and its text source of course, not an actual preview of the model). And it would save me from having to writing a browser/ deleter for GlobalData.
It would make the Blender → Codea workflow much quicker. Batch changing the extension to .txt and adding an appropriate prefix wouldn’t be that hard (you might even get the Blender exporter to do that for you. Or you could set up an automated folder action with Hazel or Automator to process .obj, .mtl files).
Export from Blender straight into Dropbox/Apps/Codea/, then in Codea open the readText asset picker, navigate to Dropbox, hit sync, select the model you require.