Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea 3.1 (203)



  • Posts: 1,705

    @Simeon - I assume you mean the World generator. Just tried it out it seemed OK until I made a few parameter slider changes and tapped on the generate button. Then it bombed out of Codea. Could it be tied up with cleaning memory after making changes that could expand memory demand if the garbage wasn’t removed?

    My previous post looked like it was exceeding the memory limit of Codea - I was trying to set up 4096 x 4096 image which used over 16 million pixels. Anyway we can trap an image or table size so that we can edit accordingly without bombing?

  • SimeonSimeon Admin Mod
    Posts: 5,362
    Are these crashes new in 203 or is this something that was an issue in 202
  • dave1707dave1707 Mod
    Posts: 8,384

    @Simeon Apparently you’re not reading all of the discussions. Farther up I replied that I ran into the editor freeze in version 202. That was just before I downloaded version 203.

  • Posts: 1,705
    @Simeon - have your recent versions been based on an older version, ie missing out on some of the geatures of the newer versions? Why I ask is that I have started to see the editing bug again when, after searching, the yellow background keyword is superimposed on editor pages.

    I thought that had been resolved.
  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 sorry about that, will read through properly. Sometimes I see the latest posts and just start responding without going through carefully

    @Bri_G it might be a different way of causing the same bug, I'll try to reproduce

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 oh I see, sorry I misunderstood

    I saw your post but when you said the editor crashes further down I thought you meant the code editor was locking up / freezing and it was a separate issue to the Craft model issue

    I will be looking at the Craft model issue as soon as possible though

  • dave1707dave1707 Mod
    Posts: 8,384

    @Simeon Quite understandable. There are times when you have a lot of discussions to read through especially when there are a lot of users posting things about new versions.

  • edited March 12 Posts: 527

    @dave1707, @Simeon the presence of the color icon on a commented line, depends how the commenting is implemented: if it is a multiple line comment block (--[[ ]]--) you will see it. It does not appear for a single line comment (--).

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 wow you weren't kidding when you said it crashes the iPad. It is definitely using a ton of memory, and it's very much the craft.models being created

    Looking into it
    - A blank Codea project uses around 180mb of memory (including the code editor and everything)
    - Your default setting of 10 uses about 700mb of memory when run
    - If I remove the surface / texture from your model it uses around 600mb of memory
    - If I remove the vertex data from your model (i.e., just an empty craft.model()) the whole scene uses around 250mb of memory

    So I would say the biggest cost is the actual vertex data. Given how tiny your tiles are this is surprising and points to a memory bug in our code.

    Your tiles are around ~264 bytes each so the entire mesh of 2500 tiles in your default settings should cost around 660kb. But it's in the hundreds of megabytes

    @piinthesky thank you I fixed the multiline comment issue

  • dave1707dave1707 Mod
    Posts: 8,384

    @piinthesky @Simeon I think that happens with a lot of things. If I comment sprite() by itself, putting the cursor between the () doesn’t do anything. If sprite() is in a multi line comment, then putting the cursor between the () brings up a list of assets. That’s been happening forever.

  • dave1707dave1707 Mod
    Posts: 8,384

    @Simeon Some changes that might make things easier.

    Add something to the editor EDIT menu at the top of the editor screen to list every asset like you have when you select > at the top right corner then ASSET when in the project list screen. Normally I have to exit a project if I want to see the full asset list. I know I can put the cursor within the () of a command, but that only list assets for that particular command. Sometimes I want to see the full list while in the editor.

    Also, something that’s slightly annoying is the long press to get the Save/Run pop up. Sometimes I press the run button wrong and I execute the code without the save/run pop up. A lot of times I have bad code that crashes Codea and I lose my changes. Would it be possible to have 2 run buttons at the top right of the editor. One that does the Save and Run and another that just Runs. Maybe label them SR for save/run and the other just R for run.

  • edited March 12 Posts: 1,705

    @Simeon - just a quick technical query: I have been thinking of tidying up my files, including my backup files obtained from @dave1707 ‘s backup project, by listing all my files sorting and eliminating duplicates. To this end I tried to use the asset list as follows:

    function setup() -- lf = asset.documents.Demos.all num = #lf print(num) end

    Needless to say this fell flat on its face - so I am asking if there is any way we can access your table/array of files when using .all in the list?

    Edit: there is a notable delay from the lf = asset. Etc line. If you comment it out drawing response is instant otherwise a delay, probably proportional to the number of files in the folder.

  • edited March 12 Posts: 1,705

    @Simeon - just noticed this (see attached photo) - is the loss of alpha values here deliberate?

    Edit: aha, if you change the default 255 it magically appears. Also, this is the case in each fill() and color() command - obviously by design , my apologies - need to take more notice when I’m programming.

  • dave1707dave1707 Mod
    edited March 12 Posts: 8,384

    @Bri_G When you first go into Codea, there’s an option to sort the project list by alpha or recent. Click on the upper right gear icon. If that’s not what you’re after, then after you do the asset.documents.Demos.all, you have to sort the table yourself.

    PS. There are several places in my backup program that you use where I do a table.sort to put files in alpha order. You can look there for examples.

    PSS. Where’s the attached photo from your above post.

  • Posts: 1,705

    @dave1707 - sorry thought the photo had attached, now has.

    Also sorry if I have mislead you. What I was trying to do was to point the assets list to my folder of backup files from your backup program. I was trying to link into the table/array that Codea uses to display the filenames. Then I was going to try to load them one by one, strip out the archived names in each backup and list the names and backup file name in a table.
    Then sort the table so that I can find any file I need and which backup files hold it. Adding the date of filing would also help. The aim then would be to make a list containing each associated file so that I could load it back into your backup project and reload the one I wished to review/modify.

    Messy, long winded but better than cut and paste from the backuo text files.

  • dave1707dave1707 Mod
    Posts: 8,384

    @Bri_G Still not fully clear on what you’re trying to do. Do you want something that will read all my backup files, pull out each project name and backup date, then sort them.

  • edited March 12 Posts: 1,705

    @dave1707 - that’s it in a nutshell. Was trying out to see if I could access list of files without manually programming them. Then intended to do what you outlined but also to add the name of each backup source file so I could see date and where each project could be found.

  • dave1707dave1707 Mod
    Posts: 8,384

    @Bri_G OK, I’ll work on that. I might have something that almost does that now.

  • Posts: 1,705

    @dave1707 - don't break a leg (or digit) but thanks - would help me sort out what I need to keep and need to dump.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 I modified your crashing Craft example to use only one model instead of creating a model for each tile. This appears to use a lot less memory, so I have a feeling the overhead in creating so many models is an issue (and something we should fix, though perhaps not this update)

    function setup()
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")        
        scene = craft.scene(),ey,ez)
    function create()
        local val=20    -- change this to 20 or higher to crash ipad
        local step=.2
        local size=200
        local groundHeight=100  
        local verts = {}
        local inds = {}
        local cols = {}
        local uvs = {}
        for x=-val,val,step do
            for z=-val,val,step do           
                local y=h:getValue(x,0,z)
                local p1=vec3(x*size,y*groundHeight,z*size)
                local p2=vec3((x+step)*size,y*groundHeight,z*size)
                local p3=vec3((x+step)*size,y*groundHeight,(z+step)*size)
                local p4=vec3(x*size,y*groundHeight,(z+step)*size)
        local pt=scene:entity()
        pt.model = craft.model()
        pt.material = cm
    function draw()
    function updateCameraPos()
    function checkTilt()
        if gx>-.001 and gx<.001 then
        if hgz == -999 then
    function update(dt)
        scene:update(dt) = vec3(cameraX,30+tilt,cameraZ),ey,0)
    function createTile(p1,p2,p3,p4,vert,ind,col,uv)
        local c=color(255)    
        local s = #vert
        vert[s+1] = p1
        vert[s+2] = p3
        vert[s+3] = p4
        vert[s+4] = p1
        vert[s+5] = p2
        vert[s+6] = p3
        for i = s+1,s+6 do
            col[i] = c
        local si = #ind
        ind[si+1] = s+1
        ind[si+2] = s+2
        ind[si+3] = s+3
        ind[si+4] = s+4
        ind[si+5] = s+5
        ind[si+6] = s+6
        ind[si+7] = s+6
        ind[si+8] = s+5
        ind[si+9] = s+4
        ind[si+10] = s+3
        ind[si+11] = s+2
        ind[si+12] = s+1
        uv[s+1] = vec2(0,0)
        uv[s+2] = vec2(1,1)
        uv[s+3] = vec2(0,1)
        uv[s+4] = vec2(0,0)
        uv[s+5] = vec2(1,0)
        uv[s+6] = vec2(1,1)
  • dave1707dave1707 Mod
    edited March 13 Posts: 8,384

    @Simeon Thanks for the new code. I’ll have to compare this to what I did to see what’s really happening so I understand it.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Ideally the one-model-per-tile method shouldn't use ridiculous amounts of memory. Although it would still use more and have more overhead, since each model has a timer and transform to store

  • dave1707dave1707 Mod
    Posts: 8,384

    @Simeon I understand what you did and I like it. I’ll have to keep it in mind and use it more.

  • Posts: 527

    @simeon @dave1707 the fps is also faster with simeon's method.

  • edited April 5 Posts: 1,705

    @Simeon - quick query, you may already have posted on this but I am struggling to find it. With the new asset listing system how can we load, read and use json files. I have a number in my Documents list in the Documents asset lister (ie all those in the root folder) which I used to us with “Documents:..“ with readText and json.decode. I can’t find the correct path format to list out these files. Could you provide an outline for it?

    edit: no need found it - I have too many files, just starting to type the file name of interest eventually pulls it out.

Sign In or Register to comment.