It looks like you're new here. If you want to get involved, click one of these buttons!
@Simeon - quick suggestion - I have just been running a project originally written by @dave1707 to run projects from a separate project list, referred to in a recent thread.
Thought it would be a good idea to provide an example which runs the examples provided with Codea from a project. I ran into the problem of addressing projects in collections. Played around with this but without success. Only way I could get it to work was to add the menu project to the Codea examples collection - then it ran.
Could we have collections added as addressable resources - a command to run them would also be useful.
Comments
@Simeon, my apologies - always pays to refer to the online documentation. Managed to get this running with using the text line “Collection:project” so I found “Examples:Lines” runs the lines demo.
Also with the new addressing mode the following ‘asset.documents.Examples.Lines’ finds the project. Will post later when I finish playing.
All,
Sorry about the slow response on this but I have not been able to get enough time to resolve the issues I have encountered. So I am posting the current state of my code (based on @dave1707 s code) with different approach. Please feel free to recommend changes.
Several points to note:
Edit: added the forgotten Carg-Bot to the project list, and corrected search and replace errors in Mesh and Shaders.
@Simeon - probably know this anyway but just noticed the search facility in the Codea editor is not case sensitive - eg search for cH an you get touched() not a problem In most cases but if you ‘Replace All’ touched() changes accordingly.
Any chance on introducing case sensitivity to the search?
@Simeon Add an option for search to allow case sensitive or not.
All,
Finally removed all the errors in the proj[] table so many of the demos work OK but some have errors related to the touched function. Above code updated, will update further when I get round the errors.
@Bri_G Try making this change to your code to fix the touched function error. Add the line str=str..”\n” . See the code below where it goes. What I found out was any tab that doesn’t have a blank line as it’s last line causes the end statement of the previous tab and the first line of the next tab to be one word. That causes an error when the code is run. The change I show forces a new line at the end of each tab. I was having trouble with Hoops n Bubbles when I tried using my original code and I tracked it down to the non blank last line of a tab.
PS. You need to add code so the touch function only works when you touch inside an example icon. Maybe it’s just the way I copied your examples picture, but if I touch outside an icon, I get an error.
All,
Finally got this running, fingers crossed, removed my local demo Chain2 from the examples collection, so changed the image and updated the code to reflect that in the code entry above. Also added code to ignore touches outside the project icons in the image. Let me know if there is an issue. Thanks again to @dave1707 for the pointers to solve the errors.
Also pulling out the parameter window gives a route back to the menu page.
@Bri_G Starting code in the very first position or not putting a blank line at the end isn’t any kind of error, but just as you said, annoying. I always start on the second line and put a blank line at the end. It’s only a problem when you combine two tabs together. The “end“ of the previous tab and the first line of the next tab are combined to form one word and then cause an error when they’re run with loadstring. It took me awhile to figure out what the problem was, but that’s the fun part of coding.
Now, with this menu project, just need to modify it for the asset style file addressing.
Thanks again for your help.
All,
Tried to use asset type addressing as follows, when applied to the above program.
Tried with require and also dofile with formatting options as below, but errors were thrown up- it appears string addressing is needed. Is there a way to get round this.
@Bri_G Not sure what you’re trying to do with the “asset.documents.Examples“. Here’s another version I had for running the Examples from a menu.
I'll add an option for case sensitive search
@dave1707 - neat example which has answered some of my problems. I am just struggling with file addressing changes and how the examples above work. I can see that a file is read in as a text file and is then run/interpreted by the Lua/Codea interpreter with the loadstr(str)() command. But I don’t know the mechanics of how tat works since two Lua scripts are in memory.
But the real problem for me was in moving from the string path creation for project files to the asset.file listing method. Just checking all seem to be stored as text. From the following edit to your code
This Ignores the path and prints out the contents of the full project list and collections.
Adding the following code after your table.sort(project) prints out the file name of
projects in the Examples project. So I am now assuming you need to use text based file addressing for projects not asset addressing.