Codea 3.1 (208)

@dave1707 is there a particular thing you’re doing where having the name is more convenient?

For now you could write an extension to string to get no extension:

function string.noExt(str)
    local rev = string.reverse(str)
    local pos = string.find(rev, ".", 1, true)
    
    if pos then 
        return string.sub( str, 1, #str - pos ) 
    else 
        return str
    end
end

Then do string.noExt(b.name)

@Simeon I don’t do anything important, just mostly write code for something to do. It’s just the old way used to give the name without any extensions, so I thought the new way could too. I do something similar to what you show above to remove the extension. I just thought since you have .ext, .type, .path, .name, it would be just as easy to have one with just the name. If not, then I’ll just continue to strip off the extension with code like you have above.

@Simeon Heres what I use to get just the name. So if you don’t want to make any changes, that’s OK.

function nameOnly(name)
    st=string.find(name,".",1,true)
    if st then
        return string.sub(name,1,st-1)
    end
    return name
end

@Simeon - had a weird crash in Codea. I pasted a few lines from a draw() function in a small project to a new blank project draw() function. There were a couple of variables in text() functions to define text positions. I ran the code before defining the variables and Codea crashed. I repeated this and it crashed again. I had to shut down my iPad at that point. Returning to it later and trying to duplicate it resulted in the expected errors of undefined variables. I have not been able to repeat this.

Prior to the crashing I was working on presenting backup file details, a la @dave1707 utility, pasting information into Codea tabs. During that I had to use Save & Run to stop losing edits. Could that have been behind the crashes?

One other thing I noticed, on the backup listings into tabs, most of the tabs had —[[ —]] commenting surrounding output in the tabs. Some of the commenting didn’t work sometimes sporadically other times all text not commented out.

@dave1707 the reason I reversed the string first is because I wanted to search “.” from the end of the string, in case of a file name like foo.bar.txt (the extension there is txt and name is foo.bar)

@Bri_G sorry about the crash, the Save & Run step is something I’d really like to fix. I have a note to look into the code around saving and will do so

@Simeon I wondered why you reversed it, never thought of that.

@Simeon @John @dave1707 - just noticed a funny whilst programming. Had my Mac and iPad running and searching on the Mac for graph plotting. I have recently downgraded from Catalina to Mojave as too many clashes and issues with Catalina. One feature Catalina introduced was the use of the iPad as a second screen - which, appeared to introduce a small icon representing the iPad next to the toolbar. This appeared on my Mac. Daft, but I thought I wonder if you have other links with this so I selected and copied some code from the forum (on my Mac) - opened a new project on Codea and told it to paste - it did!!! Is this a feature? Why is it on Mojave? If so how can I raise the iPad icon next to the toolbar as it seems to have disappeared?

Edit: tried again without the icon and the transfer worked.

Edit 2: Just downloaded a file from an old Dropbox project into Visual Studio Code on my Mac. Opened a new project up on my iPad selected the code on my Mac and pasted into my iPad - yippee - goodbye Air Code this is awesome.

@Simeon - sorry to be a pain with this but I have an issue with dependencies - that is all of my projects are presented in the list and It takes me ages (sometimes) to find the project I wish to link dependencies to. So I have a suggestion:

Don’t add all projects to the dependencies. Instead have an entry to the options when you long press on a project to ‘Add to Dependencies’. In this way you can put libraries etc that you wish to use regularly and have a relatively short list. Also, what may be useful, is if you add an option in the dependency list for each dependency project to be removed from the list.

Not a burning issue but I think it could improve Codea.

@Simeon - got my thinking cap on at the moment and a thought flashed though what’s left of my grey matter. Looking at Xcode again I began to wonder if the full Codea package is part of the engine transferred with each development package - so Craft would be included and the other libraries used within Codea. If so - does that make the resultant Xcode project pretty bulky? If so could you have support libraries etc selectable for export in an effort to reduce the final project size? Just thinking of trying to minimise issues on iPad’s with low memory - is that an issue? If not ignore this post.

@Bri_G that feature you describe is called “Universal Clipboard” which has actually been around since OS X Yosemite (!). I use it all the time and it’s one of the best features ever

Note that it works for images and video too. Often I’ll copy a screenshot on my iPad and paste right onto mac, or the other way around

Agreed on the dependency list. It should have an add button that lets you pick, rather than showing everything with a check box

On the Xcode app size, it does add some overhead to have those frameworks but not as much as you’d think. They are quite big to download, but the resulting app size is still reasonably small. I’ll keep it in mind though

@Simeon - thanks for the info on “Universal Clipboard” wasn’t aware of that feature. May have been included when I reinstalled Mojave but it means editing code gets much easier now. Thanks.

in 3d asset viewer example, what is the non-deprecated replacement for

assets = assetList(pack, "models")

i tried

assets = asset.builtin[pack].all

but the .all is sent to nil when pack is “Blocky Characters”.

relatedly there’s nothing in the docs about this. when you search for “asset” you get function assetList, and when you click that, nothing.

i’ll help with this if i can.

@RonJeffries Here’s something that lists models in Nature. When you try to get things listed, in the code, key the word asset followed by a period. Then autocomplete will give you a list of what can come next. Select something from the list, then key a period and autocomplete will give another list of what’s valid.

displayMode(STANDARD)

function setup()
    a=asset.builtin.Nature.all
    for a,b in pairs(a) do
        print(b.name)
    end
end

note what the asset viewer example is doing. it has the asset group name as strings. so it’d have to be subscripted. but asset.builtin is a user data, i think, so, i’m guessing, subscripting doesn’t work.

relatedly, if in that example you change Blocky Characters on line 14 to Blocky_Characters, you get a hard crash.

should we move this to bugs? seems ok here to me …

guessing here that this example needs to select only .obj and proceed from there, possibly trimming the names. there seems to be no direct way to select just models as assetList does.

@RonJeffries What asset viewer example are you referring to.

@RonJeffries - try this:


function setup()
    --
    a=asset.builtin.Nature.all
    for a,b in pairs(a) do
        if b.ext == "obj" then print(b.name) end
    end
end


Note: @dave1707 has already mentioned the issue of .ext inclusion in .name and @Simeon is looking into it.

3d asset viewer example in craft examples

@RonJeffries OK, found it. I was playing with 3D asset viewer and you’re correct, I didn’t see an easy way to select just the models. Maybe that’s why the example puts out the warning.

well all use of assetList does that, i think