Codea 1.5 (Beta 20)

Beta 18 is uploading. This fixes the create new class bug and a number of others I stumbled upon while working. Also removes the Swedish translation and includes the latest localizations.

Still cannot create multiple tabs with saveProjectTab().


-- Will only create tab "5" in project |pname|.
function createSomeTabs(pname)
    for i = 1, 5 do
        saveProjectTab(pname..":"..i, "-- Contents of tab "..i)
    done
end

Hello @Simeon. Are you still looking for possible shaders for the example packs? The following example from earlier in the beta testing now has suggested bindings, for added interest:

Vertex:


//
// Vertex shader: Mandelbrot
//

uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec2 texCoord;

varying highp vec2 vTexCoord;

void main() {
    vTexCoord = texCoord;
    gl_Position = modelViewProjection * position;
}

Fragment:

//
// Fragment shader: Mandlebrot
//

precision highp float;

uniform float minRe;
uniform float minIm;
uniform float fRe;
uniform float fIm;
uniform int maxIter;

varying vec2 vTexCoord;

void main() {
    int iter = 0;
    float cRe = minRe + fRe * vTexCoord.x;
    float cIm = minIm + fIm * vTexCoord.y;
    float zRe = cRe;
    float zIm = cIm;
    float zRe2 = zRe * zRe;
    float zIm2 = zIm * zIm;
    while ((iter <= maxIter) && ((zRe2 + zIm2) < 4.0)) {
        zIm = 2.0 * zRe * zIm + cIm;
        zRe = zRe2 - zIm2 + cRe;
        iter++;
        zRe2 = zRe * zRe;
        zIm2 = zIm * zIm;
    }
    float c = float(iter) / float(maxIter);
    float r = mod(c * 11.0, 1.0);
    float g = mod(c * 5.0, 1.0);
    float b = mod(c * 7.0, 1.0);
    gl_FragColor = vec4(r, g, b, 1.0);
}

Bindings:


int maxIter = 255
float fIm = 2.7/math.pow(3, ElapsedTime/3 % 6)
float fRe  = 2.7/math.pow(3,  ElapsedTime/3 % 6)
float minRe = -1.1531 - 0.8469/math.pow(3, ElapsedTime/3 % 6)
float minIm = -0.3069 - 1.0431/math.pow(3, ElapsedTime/3 % 6)

That’s fantastic, @mpilgrem. I will definitely include it under “Patterns”. Thank you.

.@Codeslinger looking into it and will fix, thank you for the report.

.@Codeslinger fixed the saveProjectTab bug — it happened when saving to an external project (i.e. not the currently running project). Next build will have this fix.

Beta 19 going up with the saveProjectTab() bug fixed.

I forgot to include @mpilgrem’s excellent Mandelbrot shader, but it will be in for the next / final build. (In the “Patterns” shader pack.)

Hello @Simeon. I have a few observations on beta 1.5(19):

  1. The print bug here still affects the beta for me, causing Codea to crash.

  2. The in-app reference for Easing Types still omits the existence of tween.easing.circIn, .circOut, .circInOut and .circOutIn (which do exist).

  3. The in-app reference for tween.stop(id) and tween.reset(id) still refer to id as being type ‘number’.

  4. Am I imagining it, or are the names of the Example Projects below their icons more transparent than the corresponding names of the user Projects? (I prefer the latter, if they are.)

.@mpilgrem thank you for this

  1. I’ll try to fix this one tonight

  2. I know they exist, but they are quite exotic easing types and add four entries to the documentation. I thought it might reduce clutter in the docs (and autocomplete) by omitting them.

  3. Fixed

  4. It does kind of look like that. I think it’s an optical illusion caused most of the backgrounds being darker towards the bottom.

.@Simeon, I see what you mean about the clutter when listing each of the tween.easing fields individually in the in-app reference. Have you considered this approach: having a page only for tween.easing and then describing its fields in the narrative for that page (as you do when documenting the easing argument of the tween() function)?

That would probably be more useful than just a list of each field (recognising that the current pages for each field of tween.easing do not currently contain any explanation of the field).

Also, the narrative for tween.easing could go on to explain the arguments that each of its easing functions take, helping users to write their own bespoke easing functions with the same structure of arguments and return value.

That’s a good idea, @mpilgrem. It does make sense to bundle them into a single page, however I am thinking at some point down the line to include an image for each of the tween.easing.* entries, showing its curve. This would justify the one-per-page approach, I think.

Unfortunately I can’t really touch the documentation anymore — every change I make causes delays due to localization, but it’s good to keep in mind for the next release.

I didn’t read through all changes but it seems to be a given that stored data always comes back as a string now (e.g. with readLocalData()) even if it is a number, at least if Jmv38 is better informed as hinted in this comment http://twolivesleft.com/Codea/Talk/discussion/comment/18140#Comment_18140 . At the moment this breaks Cargo-Bot if you enter a level set where you have gained stars.

Funny thing: I came across this problem when I got a report that it misbehaves in loveCodea.

http://twolivesleft.com/Codea/Talk/discussion/comment/18064#Comment_18064

.@Codeslinger odd, I thought I had fixed that. Thank you.

Edit: Should be fixed in the next build.

Hello @Simeon. If the ‘Arc’ shader is of any interest as an example shader (reproduced below, now with added bindings) please feel free to use it.

Vertex:


//
// Vertex shader: Arc
//

uniform mat4 modelViewProjection;

attribute vec4 position;
attribute vec2 texCoord;

varying highp vec2 vTexCoord;

void main() {
    vTexCoord = texCoord;
    gl_Position = modelViewProjection * position;
}

Fragment:


//
// Fragment shader: Arc
//

precision highp float;

uniform float size;
uniform float a1;
uniform float a2;
uniform vec4 color;

varying vec2 vTexCoord;

void main() {
    vec4 col = vec4(0.0);
    vec2 r = vTexCoord - vec2(0.5);
    float d = length(r);
    if (d > size && d < 0.5) {
        float a = atan(r.y, r.x);
        if (a2 > a1) {
            if (a > a1 && a < a2) {
                col = color;
            }
        } else {
            if (a > a1 || a < a2) {
                col = color;
            }
        }
    }
    gl_FragColor = col;
}

Bindings:


float a1 = math.pi * math.sin(ElapsedTime/5)
float size = 0.24 * math.sin(ElapsedTime/11) + 0.24
vec4 color = vec4(ElapsedTime/11 % 1, ElapsedTime/5 % 1, ElapsedTime/7 % 1, 1)
float a2 = math.pi * math.sin(ElapsedTime/7)

Thanks @mpilgrem, I will definitely include it.

Beta 20 is out. Includes @mpilgrem’s new shaders, and fixes the bug that @Codeslinger mentioned.

I tried to fix the print bug, @mpilgrem, but I can’t manage it in time. It occurs when printing lots of information (i.e. lots of print calls) in a single frame.

For everybody who is suffering from the string/number kind of bug (just in case):

If you saved a number while this bug was around, the number was saved as a string. This means that it will be read back as a string even with the fix in place, it will not be forced into number format. In the worst case you’ll have to issue a clearLocalData() or whatever applies to get your data clean again.

Or you can just write x=tonumber(x) after reading x, that will do the job, and at next save x will be saved as a number…

I’m not sure if this is new but if you use displayMode(FULLSCREEN_NO_BUTTONS) then the triple tap with 3 fingers doesn’t seem to bring back the “back” button any more.

Anyone else experience this?

.@Reefwing I think I forgot to put it back in when we re-wrote the runtime. It will have to come back in 1.5.1

Never used this function, but there might be a problem with triple tap: it is set by the ‘accessibilty’ parameters to make a zoom in the app (you are the one who showed that to me @Simeon), but i’ve noticed that when activated, the ‘3 touches’ seems desactivated in Codea (i saw that playing with Spacemonkey boucing balls: 2 or 4 touches would work, but 3 would do nothing). So are you sure in this case ‘triple tap’ will work and not be cancelled by ios?