Codea 2.3 Beta

SimeonSimeon Admin Mod
in Beta Posts: 5,054

Here's the thread about Codea 2.3 beta.

Tell me about your broken code!

«134

Comments

  • edited February 2015 Posts: 835

    I'm finding that i have to call string.format a lot more than before because decimals are appearing a lot more, and i'm adding integers

  • Posts: 1,976

    tween.delay doesn't seem to be working for me. Any idea why?

  • SimeonSimeon Admin Mod
    edited February 2015 Posts: 5,054

    @SkyTheCoder could be broken by Lua 5.3. A brief look suggests that it might need some updating to migrate from the old varargs style.

    Edit: Actually are you calling tween.delay with an integer? That might be an issue now — e.g., tween.delay(5) instead of tween.delay(5.0)

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @CodeaNoob you might want math.floor and math.tointeger

  • Posts: 2,042

    Ran through a couple of my more important current programs and fixed them.

    • I have no issues with tween.delay

    • background now wants integers (was an annoying but quick fix in my programs that animate background colors)

    • clip also now wants integers, again an easy fix.

    It'd be nice if these functions could take non-integer values and convert them for us, would make the transition easier.

  • I also ran a few of my projects and the only thing that really changed was in my binairo game, I had to add 4 lines of code, because a '0' was being shown as '0.0' but it's no big deal to change that.

    Then there's math.random... it's a shame we can't produce floats anymore, tho the easy fix would be to, for example if you want something between 0 and 1, you could just ask for a random between 0 and 100, and divide it by 100, again, not a big deal

  • SimeonSimeon Admin Mod
    edited February 2015 Posts: 5,054

    @stevon8ter math.random generates both floats and integers now. Here is the documentation

    math.random ([m [, n]])

    When called without arguments, returns a pseudo-random float with uniform distribution in the range [0,1). When called with two integers m and n, math.random returns a pseudo-random integer with uniform distribution in the range [m, n]. (The value m-n cannot be negative and must fit in a Lua integer.) The call math.random(n) is equivalent to math.random(1,n).

    This function is an interface to the underling pseudo-random generator function provided by C. No guarantees can be given for its statistical properties.

    So to produce a float in the range [0, 5) you do

    x = math.random() * 5.0
    

    To produce an integer in the range [1, 5] you do

    x = math.random(5)
    
  • @simeon sorry, silly me, I should've read the documentation :p

    thanks for the explanation :)

  • Posts: 1,976

    @Simeon Okay, I got it: collectgarbage() now stops any Tweens currently running. Kind of a big problem because it broke the entire functionality of my game I was planning to release to the App Store soon.

  • On a parallel thread - is there a way of Testflighting 2.3 and keeping the current released version (2.2) installed?

    I think i'd like if poss to run these in parallel, as I really dont want to update my code on some existing projects im working on currently and rather sandbox/ring-fence the 2.3 stuff.

    As this looks like a major update, it sort of makes sense as theres a fair bit of stuff that may break 'ongoing' projects. What do people think?

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @SkyTheCoder I'll have to look into why that is.

    @andymac3d unfortunately not. It is required to have the same identifier as the released app (on Apple TestFlight the last beta is basically the store version). The 2.3 stuff should rapidly gain maturity in the next few updates as people find and report bugs. I want it to be equivalent aside from the language changes (which are pretty minor, mostly varargs and integers, and your code should migrate towards anyway)

  • Thanks @Simeon - good to know. I'll have a look at migrating things to 2.3 over the weekend ;-)

  • Posts: 2,042

    Looping tweens no longer seems to work

  • Posts: 2,042

    @SkyTheCoder, garbage collection will take tweens that haven't been assigned to a variable yet. Going something like safe = tween() should not get collected

  • edited February 2015 Posts: 1,976

    @JakAttak It seems to be deleting some Tweens that are assigned to variables. Does the ID being in a table count? There are way too many animations to add variables for all of them.

    I tried this code:

    local _t = tween.__callback
    local _td = tween.delay
    _vars = {}
    
    local mt = debug.getmetatable(tween)
    
    mt.__callback = function(...)
        local t = _t(...)
        table.insert(_vars, t)
        return t
    end
    
    mt.delay = function(...)
        local t = _td(...)
        table.insert(_vars, t)
        return t
    end
    
    debug.setmetatable(tween, mt)
    

    But it doesn't seem to work. Any ideas?

    Edit: Flickable, my touch library, seems to be broken because of this too, because it used tween.delay(0, ...) to add its code to the touched function.

  • @Simeon I don't know if this is a bug specific to the 2.3 beta or not, but when I sync a file from dropbox, and it has the same name as an image I already had on there, but I delete that image on my pc already, then put the other one in... I then try to display the image onto the screen but get and error that a code image is expected. If I then completely close codea, and restart it, this error is gone and my image can be seen using the sprite command.

    Idk if this made any sense, and idk if this is something dropbox related or lies within codea, I just thought I'd let you know

  • Posts: 2,042

    I'm not a fan of the new underlined words for all the buttons

  • Posts: 2,161

    Memo to self: don't update Codea just before using a program in a live environment!

    (Fortunately, I realised in time and downgraded to Codea 2.2 from the App store.)

    More things that have vanished:

    • table.getn no longer works, use #table instead
    • string.gfind no longer works, use string.gmatch instead (CC devs, please note)
    • after function (...) then arg is not populated. Quick fix is local arg={...} and (if needed) arg.n = #arg.
    • getfenv/setfenv no longer exist

    That last one is pretty annoying. Lua 5.1 to 5.2 has changed how environments are handled, and I don't seem to be able to get a handle on upstream local variables any more. I can get them via debug.getlocal and if they already exist I can set them via debug.setlocal, but I can't set new ones. This is somewhat annoying.

    It therefore breaks my localisation code for conditionally selecting a particular tab to run. It also breaks some of my modifications to toadkick's cmodule library. Not sure what else is broken, and how much of it is fixable.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @JakAttak what underlined words for all the buttons? Can you show a screenshot of what you are referring to?

    @Andrew_Stacey the setfenv/getfenv is a big change. Googling around gives a few workarounds for reproducing its behaviour.

  • Posts: 2,042

    @Simeon, here's a couple of screens that show what I'm talking about:

    image
    image
    image

  • Posts: 1,976

    @JakAttak That doesn't happen for me. I think it might be some weird setting on your iPad, it looks familiar.

  • Posts: 1,976

    Okay, I fixed the tween problem. Here's some code that should fix it for anyone else that's having problems (just run it in setup, or floating in a tab)

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

    @JakAttak I believe that's an iPad accessibility setting

  • Posts: 2,042

    @Simeon, you are correct that's my bad. Someone else had my iPad for a bit, they must've kindly toggled it for me :P

  • Jmv38Jmv38 Mod
    Posts: 3,295

    All that rework necessary, and for what benefit....? :-S

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @Jmv38 the stuff happening with tween should be fixed — it's something that should not be apparent to the end user once Codea 2.3 is released properly.

    The background and clip functions will also be fixed to accept floating point values (... although clip really should be integer only. I'm tempted to leave clip as is)

  • edited February 2015 Posts: 127

    good morning @Simeon, just updated to 2.3 ( 36 ) and I have to report ( as I usually do :) ) a slight speed/performance drop. I'm talking about 5/10% in the worst cases as far as I could see
    Most of ( mainly i'd say) my code runs meshes with large spritesheets

    So what used to run steadly at 60fps is now running at 50/55fps or so.

    Ipad 3
    ios 8.1

    thank you for your great work!

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @deactive very odd, I wonder if that is attributable to Lua 5.3. I'll have to run some benchmarks to find out.

  • Posts: 489

    The example program 'Anagrams' needs a fix due to, at least, the changed behaviour of math.random(). In the Fireworks tab, line 252 might be changed to:

    ret = number - ret + 2 * ret * math.random()

  • Jmv38Jmv38 Mod
    Posts: 3,295

    hey! good to see you back @Mpilgrem

  • edited February 2015 Posts: 547

    @SkyTheCoder thanks for that :) It seems to be working for me like that, no more tween problems

    @Simeon I hereby confirm SkyTheCoders tween issue, I'd also like to report to you that the problem with dropbox I told you about earlier in this thread, only seems to occur when the file which gets replaced, has another extension than the original one

    for example, if I have an image on my dropbox (and sync it with codea) called 'bg' and that image is of the .png format. If I then delete the image of my dropbox and upload a .jpg image with the same name ('bg') and resync it with codea, the image doesn't get used (although it noticed that 2 items changed (1 deleted, 1 added))

    It's not a big deal but I thought I'd mention it anyways

    (I think this is because codea assets are actually stored with extension?)

  • dave1707dave1707 Mod
    Posts: 7,923

    @Simone Here's my speed test again and there is a slowdown. There are 2 groups of ten times. The first was times starting from the editor. The second was doing replay. The time I got when I did the original program was 7.77 seconds with Codea 2.0 on the iPad Air.

    function setup()
        loop=10000000
        s=os.clock()
        for z=1,loop do
            a=math.sin(z)
            a=math.cos(z)
            a=math.log(z)
            a=math.sqrt(z)
        end
        print(os.clock()-s)
    end
    

    started from the editor

    21.56
    21.35
    19.57
    20.98
    21.74
    20.58
    16.95
    22.63
    21.05
    22.69
    

    started using replay

    9.96
    9.01
    9.36
    9.57
    9.57
    9.05
    9.00
    9.17
    9.56
    9.02
    
  • SimeonSimeon Admin Mod
    Posts: 5,054

    @dave1707 I wonder if this is a performance regression from Codea 2.2 (as @deactive suggests). If so, that would be due to Lua 5.3.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @SkyTheCoder tweens are being garbage collected if not explicitly stored. Unsure why this change occurred, but will fix to ensure they are not collected until they complete.

  • Posts: 398

    I've been testing 2.3 with a number of my projects and everything pretty much works, apart from:

    Some fairly odd syntax checking behaviour with Fred Boggs ABCNotation class that I pinched from Cargobot (which also exhibits this issue) and now doesn't run. Looks like it's objecting to some of his string definitions - but skimming his code I can't really see what it is.

    The old stalwart JSON parser that a lot of people tend to use: dkjson.lua no longer works. Looks likely to be another varargs or string issue.

    Also a number of Codea demos no longer work:

    • Cargobot (as discussed - ABCNotation lib issue)

    • Speech.say() method not recognised in Speakeasy demo

    • Parameter.watch & String.upper(TitleText) returns nil in Parameters demo

    I'll let you know if I find some more :-D

  • edited March 2015 Posts: 835

    Also; A glitch I noticed since the Camera update,when you hit restart while usin the camera, the camera flips upside down

  • Posts: 1,976

    ContentScaleFactor isn't highlighted in gold like it used to be.

  • edited March 2015 Posts: 547

    I've encountered another issue, tho... I don't think it's codea 2.3 related...

    I'm having an image with dimensions 3451x88 and it can't be displayed with sprite... no errors tho

    I think the problem has something to do with the last answer in this discussion perhaps...?
    http://codea.io/talk/discussion/1943/abt-dropbox-folders-image-size-etc

    Since it's an 'odd' width size, or is my image just to big? I'm sorry if this isn't the appropriate topic to place it in, but I thought I might as well place it here as I haven't had the chance to test it in 2.2

    EDIT: I was able to load the image, tho I had to save it to documents first, it only had this problem when loading from dropbox (the image in the documents is way smaller tho...)

  • edited March 2015 Posts: 2,042

    @stevon8ter, It's because that image is larger than the maximum allowed size (which I think varies per iPad - something like 2048 x 2048 or 4096 x 4096)

    If you have a newer iPad which sound be 4096 max, try storing the image with readImage and spriting that rather than spriting the file name directly.

  • Posts: 547

    @JakAttak loading with readImage worked indeed, tho I thought the ipad 3 should have the capacity to use 4096x4096, so idk why the direct spriting acts funky

  • Posts: 2,042

    @stevon8ter, yup sounds like it might be a bug since it works with readImage

  • Posts: 1,976

    @JakAttak The maximum image size is 4096 / ContentScaleFactor. The reason newer iPads have a max of "2048," is because it is actually 4096, but the retina screen doubles it.

  • Posts: 455

    I've been playing with 2.3 and generally apart from some string formats needing to be %f rather than %d for integers my projects all seem fine.

    I had a bit of a play on integers and performance and they don't seem to make a big difference, I remember the days of old school machines like C64s etc integers were massively better, I guess in the world of modern CPUs float performance is so good that changing things to ints doesn't give you a boost...

  • Posts: 688

    My stuff all appears to be working correctly with the exception of having to fix the parameters to clip to be integers. Whilst I agree with @Simeon that they should be integers anyway, I would have thought a simple cast / conversion on the back end might make the function more accessible to beginners and that a back end cast is probably faster than having to call math.floor() from Lua.

    Although generally speaking clip isn't normally the kind of function you call many times per frame anyway.

  • Posts: 688

    One question though - when exporting code for app store release, will the 2.2 or the 2.3 version of the run time be used - and will it make a difference as most of the 2.3 fixes would appear to backwards compatible (well apart from the setenv stuf).

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

    @TechDojo if you export from Codea 2.3 then the resulting project will use the 2.3 library, which includes Lua 5.3. If you export from 2.2 it uses the 2.2 library. (The Xcode libs are tied to the version of Codea.)

  • Posts: 688

    @Simeon - thanks that's great. I'm hoping to submit a new update in the next couple of weeks so I'll be doing it with the new 2.3 libs (unless you specifically don't want me to).

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @TechDojo it's fine to use the new libs if they work for you. Note that the next beta of Codea 2.3 should fix your setting WIDTH / HEIGHT issue, let me know if it causes any problems.

    Also note that the Codea 2.3 libs downloaded by Xcode are updated every time a new beta build comes out, so if you have an exported project you might want to delete the libs (.a files) so that Xcode is forced to download fresh ones.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    LuaSocket

    Codea 2.3 (37) includes LuaSocket. These are the socket and mime global tables.

    The plan is to keep these in Codea for future internal developments (e.g., debugger), but they should be available for you to use in your projects. I do not really like the socket API, and I don't think it fits well with Codea, so I don't plan to include documentation. You can find the documentation online.

  • Posts: 688

    @Simeon - thanks. Just to confirm, I've just picked up the new build and i got the request to update the examples and 'Anagrams' worked out of the box.

    Also the fix to updating of WIDTH & HEIGHT appears to work correctly as well :) :)

Sign In or Register to comment.