Codea 2.3 Beta

24

Comments

  • dave1707dave1707 Mod
    Posts: 8,400

    @Simeon Not sure what you changed for 2.3(37), but I ran my above speed test and the average time from the editor was 8.39 and the average time for replay was 8.62. Both averages were for 10 runs each. The run from the editor was a large decrease in time and the run from replay was also a decrease in time.

  • Posts: 398

    Parameter and Speakeasy demos still fail on this version. Cargobot now works.

  • dave1707dave1707 Mod
    Posts: 8,400

    @Simeon Not sure if this was mentioned or if this is really a problem, just not what I expected. This code draws a circle in Landscape mode. If the ipad is in portrait orientation when the code starts, an ellipse is drawn. When rotated to landscape, it flips to the circle.

    supportedOrientations(LANDSCAPE_ANY)
    
    function setup()
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        ellipse(WIDTH/2,HEIGHT/2,300)
    end
    
  • SimeonSimeon Admin Mod
    Posts: 5,364

    @andymac3d any info on how they fail for you? They work for me. Do they fail for anyone else?

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @dave1707 great find, thank you, I think this relates to the settable WIDTH / HEIGHT change I made to fix @TechDojo's issue.

    I'm not sure why the speed has increased, there weren't any performance related changes made.

  • dave1707dave1707 Mod
    Posts: 8,400

    @Simeon For the Parameter demo, the print for the X value as you move the slider prints a long number, whereas on the slider it's 2 digits past the decimal point. That's the only thing I can see that might be wrong.

  • toffertoffer Mod
    Posts: 151

    LuaSocket, so great!!! grrr a ton of work and no time to test. Also it seem that sometimes the ip binding from a tcp fail (to the default 0.0.0.0). Thank's a lot for this addition!

  • Posts: 398

    @Simeon - appears it was 'operator error' on my part. I'd inadvertently modified those demos previously whilst looking at something else.

    However, I'm sure the 'old' Codea behaviour a number of iterations ago was that changes to the demos were never saved? I think it might be easier to encourage people to duplicate the demos before modifying them else beginners could easily mess them up ( like what I just did :-) )

    Also, is there a way of copying the contents of the output pane? Something like: output.copy (that then copies it to the clipboard) - it occurred to me this would be useful for debugging.

  • toffertoffer Mod
    Posts: 151

    @andymac3d - touch an entry of the output pane and it will be copied to the clipboard, an other solution could be overriding the print function?

  • Posts: 398

    Good stuff @toffer - never realised that! Well you learn something every day!

  • dave1707dave1707 Mod
    Posts: 8,400

    @toffer @andymac3d The only problem is each print goes to seperate area, so you can only copy one print line at a time. There have been times where I wanted to copy a lot of print lines at once but couldn't.

  • toffertoffer Mod
    Posts: 151

    @dave1707 - Something I've done to simulate buttons (question with multiple choices) from the output panel was to check the clipboard content in the draw loop, each time it was changed from it's previous value, mean the user has touched the output panel, so I could trigger something depending on it. Maybe it can be applicable to build a clipboard buffer, each time the clipboard has changed, take it's value, push it to the buffer and replace the clipboard with the content of the buffer?

  • dave1707dave1707 Mod
    Posts: 8,400

    @toffer One thing I would do if I wanted to select what was printed was to concat innate everything to a string and then print the string at the end. All of the information being printed would print in one print area and able to be copied. Of course I don't do that very often.

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @toffer that's a pretty brilliant way of detecting touches in the output area.

  • Posts: 835

    In the new update, the camera still flips upside down when you hit restart during live feed

  • Posts: 2,043

    @Simeon, when saveText creates a file for you, it adds a period to the end of the file name, and it now fails to edit any text file if the file doesn't have an extra period at the end (ex saveText("Project:Example", "test") won't save anything to Project:Example, but will to Project:Example.

    Also, I had a Parameters program in my regular projects section, as well as one in my examples section, which get confused between each other when closing, opening, or editing. (one is not a copy of the other, just a program with the same name) Since they are in different collections I would expect they wouldn't mess with each other.

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @JakAttak thank you for finding that, I think I know what the cause is. Will fix for next update.

    Will look into the confused collections issue. I believe one of them actually has a different name — it's just that the "localized" name is showing instead on your copied version.

  • Posts: 2,043

    @Simeon, sounds good.

    Not sure if anyone has mentioned this yet but tweens can no longer take zero as the time, any reason for this?

  • Posts: 1,976

    @Simeon The LuaSocket API in Codea seems to be different from the standard, none of the examples from the tutorials I've looked up have worked in Codea. They all call local socket = require("socket"), which doesn't return anything in Codea, if I try to call socket.tcp() and use that as the socket object, it gives errors on socket.bind(...), saying it expected some weird "socket{master}" variable as the first parameter or something. Just calling socket.bind gives a nil error, etc.

    Is there any documentation on Codea's version of LuaSocket?

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @JakAttak they never could (it used to bump the value to 0.001 or so) but I figured actually asserting this is better behaviour for the API. If you want to do a 0 tween, then you'll just have to use a very small value.

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @SkyTheCoder Codea uses LuaSocket 3.0, documentation is on the github repo here https://github.com/diegonehab/luasocket/tree/master/doc

  • edited March 2015 Posts: 1,976

    @Simeon Do you think you could re-add bumping the 0 to a 0.001 in the tween library? It kind of broke most of my libraries, where I used tween.delay(0, ...) to run code after 1 frame had passed (usually to hook into the draw function). Maybe just put a warning when you use it, like what happens when you call watch(), parameter(), etc.

    Edit: here's a fix that automatically changes it to 0.001, but not everyone might have it, so I still would want it to be built-in:

    _vars = {}
    
    local mt = debug.getmetatable(tween)
    
    local _t = mt.__call
    
    mt.__call = function(del, ...)
        local delay = del
        if delay == 0 then
            delay = 0.001
        end
        local t = _t(delay, ...)
        table.insert(_vars, t)
        return t
    end
    
    local _td = tween.delay
    
    tween.delay = function(del, ...)
        local delay = del
        if delay == 0 then
            delay = 0.001
        end
        local t = _td(delay, ...)
        table.insert(_vars, t)
        return t
    end
    
    debug.setmetatable(tween, mt)
    
  • SimeonSimeon Admin Mod
    Posts: 5,364

    @SkyTheCoder I could add the 0 case support just to tween.delay and maybe a version which just accepts a callback (tween.delay( func ))

  • Jmv38Jmv38 Mod
    Posts: 3,295

    @SkyTheCoder wow, you've got pretty fluent with metatables! Why do you use different methods for the 2 functions? Why not overwriting tween() function directly, as you do for tween.delay, instead of redefining mt._call? Just to know.

  • Posts: 1,976

    @Jmv38 Tween is actually a table/metatable, not a function, the only reason you can call it like a function is because metatables can have a _call function.

  • SimeonSimeon Admin Mod
    edited March 2015 Posts: 5,364

    @SkyTheCoder does this work for you?

        local t = socket.tcp() 
        assert(t:bind("*", 5088)) 
        t:close()
    

    Edit: I Think I see the problem, never mind. Will fix for next build.

  • toffertoffer Mod
    edited March 2015 Posts: 151

    @SkyTheCoder - socket.bind is a shortcut method not implemented in this version (also I didn't find it).
    It seem that the the host binding fail often, that's not a big deal. Not tested but I think with a check, closing and re-bind it could work.

    A dummy repl to test from a telnet connection (change the host with your local ip)

    function setup()
        server = socket.tcp()
        -- Replace with your local IPad ip
        server:bind("192.168.1.23",52096)
        server:listen()
        server:settimeout(0.0)
        local ip,port = server:getsockname()
        print("please telnet to", ip, "on port", port)
        client = nil
        buf = {}
    end
    
    local _twu = tween.update
    tween.update = function(...)
        if not client then
            client = server:accept()
            if client then
                client:settimeout(0.0)
                local ip,po = client:getsockname()
                client:send("Welcome to the REPL mr(s) "..ip.." "..po.."\n")
                client:send("Type bye to quit\n")
            end
        end
        if client then
            local lin, err = client:receive()
            if not err then
                if lin == "bye" then
                    client:close()
                    client = nil
                else
                    table.insert(buf,lin)
                    local f,e = load(table.concat(buf,"\n"))
                    if not e then
                        f()
                        client:send("> eval\n")
                        buf = {}
                    end
              end
            end
        end
        _twu(...)
    end
    
  • Posts: 398

    As part of the Codea comms/sockets discussion - can anyone recommend a good Lua JSON parser/encoder for Lua 5.3? Seems most of the ones I've found/used only work with previous versions.

    It would be great if there was some native support within Codea for this, as serialising/un-serialising data (from the web or otherwise) is really useful.

  • toffertoffer Mod
    Posts: 151

    @andymac3d there is some filters in the mime table (no json one) : http://w3.impa.br/~diego/software/luasocket/mime.html. +1 for native json support.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    @Andymac3D JSON libs dont work any more? Do you mean the great tool to post gists doesn t work any more?

  • Posts: 398

    @Jmv38 - I would certainly test your old code that use any legacy JSON libs. Certainly dkjson.lua doesnt work for me (which is popular one) and a couple of others i've tried.

    Would be useful if others can investigate this further as well (but probably outside the scope of this thread) I suspect it does have some implications for legacy code I guess.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    @andymac3D Juce made a fantastic gist uploader that uses DKjson. http://codea.io/talk/discussion/comment/48060/#Comment_48060.
    I guess now i doesnt work any more if DKjson is broken.... So much rework to do :((

  • edited March 2015 Posts: 398

    @Jmv38 I'd certainly try it before you slash your wrists ;-)

    p.s. It may just need a bit of tinkering to update the library - but theres an awful lot of involved string parsing it appears to do, its just finding the time. However, updating other peoples code is often a pain in the arse :-/

  • SimeonSimeon Admin Mod
    Posts: 5,364

    Next build will have fixed sockets library. Thanks @SkyTheCoder for pointing out the missing functions.

    I will look at porting the dkjson library and perhaps integrating it.

  • SimeonSimeon Admin Mod
    Posts: 5,364

    Just a note that the latest dkjson library does work fine with Lua 5.3. I will have it built-in in the next build.

  • Posts: 2,043

    @Simeon, this is great news about dkjson being built in, thanks.

  • Posts: 398

    Thanks @Simeon, great news! ( It appears the site I'd been using to pull data off had some badly formed JSON feeds for some reason - apologies to @Jmv38! :-)

  • Posts: 688

    Not sure if it's a 2.3 thing or it's always been there - but how do you access code tabs using Aircode when they're off the right of the browser window. As soon as the tab list gets bigger than the desktop resolution you don't seem to be able to access them at all.

  • SimeonSimeon Admin Mod
    edited March 2015 Posts: 5,364

    Here's the plan for the next build:


    Private Libraries

    You can use these in your projects but they will not be documented. They will be used to build other Codea features:

    These are not imported into the global namespace by default, to use them you'll need to import them using require, e.g.

    -- Import lpeg for current tab
    local lpeg = require("lpeg")
    
    -- Import socket for all tabs
    socket = require("socket")
    

    (Side note: LPeg is an incredible pattern matching language implemented as a native C library. The dkjson parser claims to make use of it for a significant speedup, so it now exists in Codea to implement dkjson optimally.)


    Public Libraries

    These are in the global namespace by default.

    • dkjson available as json

    You should just be able to use json.decode and json.encode from anywhere.

  • SimeonSimeon Admin Mod
    Posts: 5,364

    2.3 (38) should fix the missing functions in socket, as well as saveText. It also includes the libraries mentioned above.

  • Posts: 688

    Initial tests on my app on 2.3 (38) appear ok.
    I'll replace my internal JSON library with the json one and let you know how that works.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    these libs look really cool!

  • Posts: 2,043

    @Simeon, this all sound great. I've tested saveText and it is working properly, great. loadstring is a pretty huge deprecation, I'm wondering if it might be a good idea to keep it as a compatibility function that just calls load, like http.get

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @JakAttak loadstring is still there and just calls load. But it's not highlighted or auto completed to discourage use.

  • Posts: 2,043

    @Simeon, ah I spoke too soon there. My issue wasn't load string, it was that readText doesn't work with files created by saveText.

    Try this:

        saveText("Project:weird", "interesting")
        print(readText("Project:weird"))
    
  • SimeonSimeon Admin Mod
    Posts: 5,364

    Thanks @JakAttak, will fix.

  • toffertoffer Mod
    Posts: 151

    A strange behavior with multi-texture shader when rects not sized to original image size nor power of 2. Colored noise is drawn in place of image. Example code can be found here : https://www.dropbox.com/s/7k5f7i0y1xgl9rw/multi_tex_bug.lua?dl=0

    Btw, I don't know if it's possible and there is more important stuff, but, it would be great to have mesh 'drawArray modes'.

    something like that:

    mesh:draw([TRIANGLES|TRIANGLES_STRIP|LINE|POINT...], [start, count])
    
  • SimeonSimeon Admin Mod
    Posts: 5,364

    @toffer strange! Was that happening in a previous version?

  • SimeonSimeon Admin Mod
    edited March 2015 Posts: 5,364

    @toffer it appears to be lack of precision on the iPad GPU

    Modifying to check the texture id within an epsilon corrects the rendering.

    void main()
    {
        //Sample the texture at the interpolated coordinate
        highp vec4 col;
        if (vTex > 0.99 && vTex < 1.01) { col = texture2D( texture1, vTexCoord ) * vColor; }
        if (vTex > 1.99 && vTex < 2.01) { col = texture2D( texture2, vTexCoord ) * vColor; }
        //Set the output color to the texture color
        gl_FragColor = col;
    }
    
  • toffertoffer Mod
    Posts: 151

    @Simeon - Ok. yep in previous version too. That's strange, why it not happen when rect size is power of 2 ?

Sign In or Register to comment.