Codea 3.1 (203)

@Simeon - little demo to show slow spriteing plus also a call to a non-existent sprite (pre asset lists} which throws up the last sprite.


function setup()
    --
    spr1= readImage(assets.documents.project.tile19)
    spr2 = readImage(assets.documents.project.tile18)
end


function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    spriteMode(CENTER)
    sprite(spr1,192,720)
    sprite(spr2,576,720)
    sprite("Documents:any",192,640)
end

p.s. replace project.tile19 and project.tile.18 with your own sprites and leave the rest as is.

@Simeon for me version 200 crashes on startup and cannot be used

@piinthesky damn, thank you for the report. I’ll look into it now

@piinthesky are you able to install an older build for now? I’ll need to look into this more deeply and I don’t have time tonight. I’m curious if this build crashes for everyone (seems to work fine for me)

@Simeon - not had chance to load 200 on mine yet. Do you run on iPad or simulator before publishing? Will report on 200 later. If I find it crashed I’ll probably wind back to 197, anh other siggestions?

@Simeon Version 200 works OK for me.

img=image(CAMERA) works OK.

@piinthesky Try loading an older version from the App Store and then try reloading version 200. Maybe it didn’t load right.

Powered on/off 200 - crashes
Went back to 199 -ok
Went back to 200-still crashes
Went back to 199-happy

I am on ipad pro 12.9, IOS 13.3.1

@piinthesky I loaded version 200 on my 12.9” iPad Pro 1 with iOS 13.3.1 and everything is OK.

@Simeon - loaded version 200 on my iPad Pro and ran noticeable improvement in speed for the short sprite routine above and address selection, but it still displayed the non-existent third sprite as the second sprite in the list.

My old 3D models using the addressing prior to the asset.lists worked but a more recent one, addressing with asset.list crashed Codea.

@Simeon - after closing Codea and re-running 200 all code seemed to work fine. No crashes - weird!!!

@simeon, @dave1707 @Bri_G this time i made sure that codea was exited before doing the testflight update and this time 200 works? I guess previously codea was open when i did the update- i don’t know if that could be a reason for the crash.

@dave1707 - just out of interest how did you time the display of the model that you mentioned in one of your earlier posts? Wasn’t sure how you’d trap an event like that.

@Simeon - I have a number of data tables which contain paths to textures etc on Dropbox. They tend to be in sub directories but Codea can not see these so we were able to use them by typing in the full path. Could you tell me how I would address a subdirectory using the asset.list procedures in 200 ?

Also - with the new addressing are there any illegal characters that we have to avoid in storing resources in sub-directories?

@Bri_G Heres how I do timeings.

function setup()
    s=require("socket")
    st=s:gettime()
    
    for z=1,1000000 do
        a=math.sqrt(z)
    end
    
    en=s:gettime()
    print(en-st)
    
end

@dave1707 - yup that’s great using sockets but how do you trigger printing out the time after loading and displaying an obj model?

@Simeon - just restarted iPad, loaded Codea and loaded up 3D obj viewer and Codea bombed. Re-started Codea, ran same project and it worked. It’s almost like something needs initialising in first start then it’s OK. Still using 200.

@Bri_G I think the optimisation I put in for the picker speed update is to blame for this weird behaviour. I’ll have to revert it which may make the picker slow again until I can find a better way to improve speed.

For subdirectories, just type them out like normal

local tex = assets.documents.Dropbox.My_Folder.My_Subfolder.MyFile

Codea should autocomplete the subdirectories so you can be sure they exist. Codea’s autocomplete suggestions will give you “safe” versions of the names you can use, some names will not be able to be translated and so will not appear in the suggestion list (file/folder names containing parentheses in particular)

If you want to access them dynamically you can use the bracket syntax:

local tex = assets.documents.Dropbox["My Folder"]["My Subfolder"]["MyFile.png"]

(This requires that you know the file names)

If you want to list the files in a particular Dropbox subfolder you could do:

local textures = {}
for k,v in pairs(assets.documents.Dropbox.My_Folder.all) do
    if v.type == SPRITES then
        table.append(textures, v)
    end
end

Then you could use those textures with sprite / mesh / craft / shaders / readImage or whatever

@Simeon - thanks for that it clarifies you previous note on syntax.

@Simeo @dave1707 - OK guys this is going to seem a bit weird. The recent bombing occurred after an update which I added whilst playing with 3D. This morning I was getting erratic bombing with other projects even bombing to starting Codea which suggested retained configuration in memory is issue. Random running projects after Codea reset was inconsistent with one project that always bombed. I since found if I run two projects before the bomber that the bomber works. So could you try this with a project that you find always bombs.

Load the two projects below then run the first, run the second and then run your bomber.

First:


-- Craft Template

displayMode(OVERLAY)
function setup()
    parameter.integer("x",-180,180,0)
    parameter.integer("y",-180,180)
    parameter.integer("z",-180,180,0)

 -- Create a new craft scene
    scene = craft.scene()

 -- Move the main camera position
    scene.camera.position = vec3( 0, 0.04, -0.4)
    CameraSettings = scene.camera:get(craft.camera)
    CameraX = 0
    CameraY = 0
    CameraZ = 0
    FieldOfView = 60
    Ortho = false
    OrthoSize = 5
    
    -- Set camera rotation + position viewing center of the scene
    scene.camera.eulerAngles = vec3(CameraY, CameraX, CameraZ)
    scene.camera.position = -scene.camera.forward * 5

    -- Adjust the scene lighting
    scene.sun.rotation = quat.eulerAngles( 45, 150, 0)
    scene.ambientColor = color(181, 98, 98, 255)

    -- Get sky material and alter sky and horizon colors
    local skyMaterial = scene.sky.material
    skyMaterial.sky = color(32, 36, 193, 255)
    skyMaterial.horizon = color(92, 29, 214, 255)

    -- Create a new entity
    e = scene:entity()
    e.scale = vec3(1,1,1) / 20
end

function update(dt)
    -- Rotate the entity
    e.eulerAngles = vec3(x,y,z)
    
    if CurrentTouch.state == MOVING then 
        CameraX = CameraX - CurrentTouch.deltaX * 0.25
        CameraY = CameraY - CurrentTouch.deltaY * 0.25
    end
    
    CameraSettings.fieldOfView = FieldOfView
    CameraSettings.ortho = Ortho
    CameraSettings.orthoSize = OrthoSize
    
    -- Set camera rotation + position viewing center of the scene
    scene.camera.eulerAngles = vec3(CameraY, CameraX, 0)
    scene.camera.position = -scene.camera.forward * 5

    -- Update the scene (physics, transforms etc)
    scene:update(dt)
end

function draw()
    update(DeltaTime)
    scene:draw()       
end

Second:


function setup()
    --
    spr1= readImage(assets.documents.project.tile19)
    spr2 = readImage(assets.documents.project.tile18)
    spr3 = readImage(assets.documents.project.tile20)
end


function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    spriteMode(CENTER)
    sprite(spr1,192,720)
    sprite(spr2,576,720)
    sprite("Documents:any",192,640)
    sprite(spr3,576,648)
end


On the second one you’ll have to set up a project with 3 sprites in but don’t change the line which says ‘Documents:any’ in.

I know this feels a bit weird but hopefully you’ll be able to reproduce this and it may give Simeon an idea why the error is occurring.