Codea 1.5 (Beta 8)

@Jmv38 yep, I work in portrait, and that’s where I’m seeing it. In my current project I’m encoding “levels” for a game in comma delimited strings, and if I let them spill past a line they become jumbled.

Sorry - was AFK for the holiday mostly.

@jmv38 - what you’re seeing is apache giving you a directory listing, rather than executing the cgi script. Try renaming it to “index.cgi”, or calling it explictly (ie. your URL would end in /bortels.cgi).

Otherwise, that should work. I literally cut and pasted the code from my working version.

And - to explain further - the content of “bortels.cgi” is running on the server, not on your ipad. You want the resulting data file to reside on the webserver, so the code that writes it needs to live on that webserver.

I like the firebase stuff - but it explicitly hands off part of your infrastructure to a third party, whose goals and priorities may (OR MAY NOT) coincide with yours. It’s great for hobby and messing around; but I wouldn’t trust anyone but myself (or someone I’m paying, and even then I’m iffy about it) with my data if money was riding on it. (disclaimer: I do server side code and support for home banking for a living, and my levels of distrust and requirements for uptime are through the roof… if you’re just looking for a casual highscore server, and your reaction to data loss is “bummer” - and it should be for casual stuff - then things like firebase are probably more than enough)

Loading too many images into the GPU crashes Codea. The number is about 30 (full sized, iPad4), but obviously depends on other stuff loaded in. Thing is, I only need to display about 7 at a time but they aren’t always the same seven so when loading new ones in the number can get high enough to crash the system if I’m not careful.

.@Andrew_Stacey do you maintain references to more than 30 at times? Codea will garbage collect when a low memory warning is received — so if you have images that have no references in your code, they will be deallocated. But if you are keeping references then there is nothing we can do to prevent the crash.

.@Mark @Jmv38 apologies on the editor issues. I’m experimenting with a re-write at the moment. In the mean time I will try to improve the current implementation — if you have some code that consistently recreates the buggy behaviour that would be great.

.@Codeslinger thanks for your bug report.

Cursor movement and selection keys do not include the last character of a tab. (Not counting the annoyances of the last line, e.g. if I add “function f(t)” in the last line then the helpful autocomplete buttons keep me from tapping to the right of the parenthesis.)

Can you explain this one a little more? When you say “last character of a tab” do you mean the last space in the four spaces inserted by the tab key?

Good point about the autocomplete overlap. I’ll look at making it auto-scroll the editor up when autocomplete pops up.

When browsing the help docs and hiding the keyboard (when search was active) the list frame scrolls a bit and the topmost entry is offscreen. You have to carefully scroll up to not enter search mode again.

So the steps to recreating this are:

  1. Show docs
  2. Go into search
  3. Hide keyboard

Is that right? I’ll give it a try

Only global storage works for me. saveLocalData() and saveProjectData() seem to have no effect. Or is it the companion read and list functions?

Sorry, I need to re-implement these. The Codea runtime (and other components) went through a fairly significant rewrite with this release. Some features haven’t made it back in yet.

Cannot get saveProjectTab() to work. Read and list works. Is it true that I can only create new tabs in existing projects? saveProjectTab() works to the extend that it complains if I name a non-existing project.

I’ll look into this one.

Hello @bortels. I tried:
http://jmv38.comze.com/bortels/bortels.cgi?data=JMV38_first_try.
This returns the listing of bortels.cgi. I also tried:
http://jmv38.comze.com/bortels/bortels.cgi .
Its he same. After running those i tried just the data again: result is directory listing, as before.
Maybe i have not correctly activated cgi scripts? On the web they often say there are many many problems to solve before it work (this i why i don’t like web programming and much much prefer Codea)

@simeon. Thanks for being back among us (ok, let’s say you can have 3 days off for christmas, :wink: ). With my new game (see christmas gist) Codea crashes when i play for a long time and switch levels. I have added collectgarbage() at some key location, but i don’t know if it really helps. I hope it is an instability of 1.5(8), which seems to have some, and that it will be solved later. Or is it my code? I have the feeling my code is ‘clean’ (no memory leak), but who knows? Is there a LUA function that i could use to check memory increase?

.@Simeon I’m trying to minimise how many images I’m holding at any one time. The difficulty is that some of them need to be saved before they are discarded and saving several full-scale images is expensive. Plus it is possible that I want to reuse one straight away, so I have a cache that holds the images and gradually saves them back to disc. The difficulty is if I work too fast and fill up the cache before I can safely empty it.

Is there a function that returns the amount of memory in the GPU? I read about gcinfo() (.@Jmv38 take note of that) but it doesn’t seem to be affected by stuff loaded into the graphical memory. If I could read that, I could fine tune my program a bit more systematically than just counting crashes.

Mentioned in the previous thread that i had some problems with physics joints, but it was my own mistake so ignore that bug report. My joints were garbage collected, since I’d forgot to have any references to them.

If a cgi call returns the cgi content, it means the server is not interpreting the script as a cgi script (and calling it). For a “.cgi” file (as opposed to a script-alias directory like cgi-bin), things to look at (assuming apache):

  1. “Options ExecCGI” needs to be on for the context you’re serving from - it looks like this on my box at home:
        <Directory /var/www/>                                                                                            
                Options ExecCGI Indexes FollowSymLinks MultiViews                                                        
                AllowOverride All                                                                                        
                Order allow,deny                                                                                         
                allow from all                                                                                           
        </Directory>                  
  1. You need to be sure you have a mime-type handler that recognizes .cgi - I have the following in my mime.conf:
AddHandler cgi-script .cgi

Where are you hosting, and/or what platform? There are many, many places this can get messed up, but any good hosting service should have docs on how to enable cgi scripts.

But yes - unlike a nice prepackaged environment like Codea, this is sometimes a bit of a chore to make work.

Bug Having ]] in a block-commented region causes an error (such as a[b[2]])

Thanks @Bortels.
I am at 000webhost.com.
The code lines you listed up there, should i put it in the .htaccess file?

Clarification: “Cursor movement and selection keys do not include the last character of a tab.”

I mean an editor tab, i.e. the whole text buffer. That’s why it was so annoying to be stuck at the last line to the left of the parentheses, I couldn’t move beyond it using the cursor key.

Does the code below reveal a bug in beta 1.5(8)? I wrote it thinking about punching a hole in a rectangle. On an iPad 2 with iOS 6.0.1 sometimes (but not always) some of the triangles in the mesh do not render - pressing the ‘replay’ button a few times reveals the problem:


--
-- RectWithHole
--

supportedOrientations(LANDSCAPE_ANY)
function setup()
    myRwh = RectWithHole(400, 300, WIDTH/2, HEIGHT/2, 100, 55, 90)
end

function draw()
    local r = math.sin(ElapsedTime * 2) * 64 + 127
    local g = math.sin(ElapsedTime * 4) * 64 + 127
    local b = math.sin(ElapsedTime * 6) * 64 + 127
    background(r, g, b)
    myRwh:draw()
end

RectWithHole = class()

function RectWithHole:init(width, height, posX, posY,
    holeX, holeY, radius)
    width = math.abs(width) / 2
    height = math.abs(height) / 2
    radius = math.min(math.abs(radius), width, height)
    holeX = math.min(math.max(holeX, radius - width),
        width - radius)
    holeY = math.min(math.max(holeY, radius - height),
        height - radius)
    self.width = width
    self.height = height
    self.posX = posX
    self.posY = posY
    self.holeX = holeX
    self.holeY = holeY
    self.radius = radius
    self.mesh = mesh()
    local segNo = math.max(4, math.floor(math.pi * radius / 30))
    local dAng = math.pi / 4 / segNo
    local dEdge = 1 / segNo
    local org = {
    vec2(width, holeY),
    vec2(width, height),
    vec2(holeX, height),
    vec2(-width, height),
    vec2(-width, holeY),
    vec2(-width, -height),
    vec2(holeX, -height),
    vec2(width, -height)}
    local dir = {
    vec2(0, dEdge * (height - holeY)),
    vec2(-dEdge * (width - holeX), 0),
    vec2(-dEdge * (width + holeX), 0),
    vec2(0, -dEdge * (height - holeY)),
    vec2(0, -dEdge * (height + holeY)),
    vec2(dEdge * (width + holeX), 0),
    vec2(dEdge * (width - holeX), 0),
    vec2(0, dEdge * (height + holeY))}
    local ver = {}
    local col = {}
    local p1 = vec2(holeX + radius, holeY)
    local p2 = org[1]
    for i = 0, segNo * 8 - 1 do
        local seg = math.floor(i / segNo)
        local dSeg = i % segNo + 1
        local ang = math.pi / 4 * seg + dSeg * dAng
        local p3 = vec2(holeX + radius * math.cos(ang),
            holeY + radius * math.sin(ang))
        local p4 = org[seg + 1] + dSeg * dir[seg + 1]
        table.insert(ver, p1)
        table.insert(ver, p2)
        table.insert(ver, p4)
        table.insert(ver, p4)
        table.insert(ver, p3)
        table.insert(ver, p1)
        p1 = p3
        p2 = p4
        -- Random colours for debugging only
        local c = color(math.random(127) + 127,
            math.random(127) + 127, math.random(127) + 127)
        for j = 1, 6 do
            table.insert(col, c)
        end 
    end
    self.mesh.vertices = ver
    -- Set vertex colours for debugging only
    self.mesh.colors = col
end

function RectWithHole:draw()
    pushMatrix()
    resetMatrix()
    translate(self.posX, self.posY)
    self.mesh:draw()
    popMatrix()
end

function RectWithHole:fill(color)
    self.mesh:setColors(color)
end

.@mpilgrem thank you for posting that code. It is very strange behaviour. I’m looking into it now.

Edit: with lower values for segNo the effect seems to disappear.

Edit: also the bug doesn’t occur with 1.4.6 — I’ll have to ask @John for help with this, seems to be a mesh related issue.

.@mpilgrem @John has found the issue — it occurs when using vec2s in a mesh. Their z-value is uninitialised. This leads to artefacts on thin triangle strips.

To fix this for now please use vec3 in your mesh with a z value of 0. This doesn’t affect 1.4.6 and will be fixed in 1.5 (9).

Hi. Nice with an update. The expression key is a bit buggy if you press it down and then move quickly to the number keys. Then the keyboard gets grey and it seems like I move the cursor in the code view instead. Also, I think it would be nice if the expression input is canceled if I end the touch event on the expression key.

Gravity and sound seems to work fine now, good work!

Btw, anyone have any shader examples using lightning? Would be nice to try out a bit, but haven’t had the time to write any code yet. :slight_smile:

My toroidal Game of Life using shaders had a simple lighting/shadow shader in it so that the torus looked as if it were lit from one angle. No shadows, though (by which I mean that one part of the torus did not cast a shadow on the other). I did this by loading the normals in to the shader using a buffer. I don’t remember if I posted the code already … I think I’m getting to the point where I’ll have to keep an public repository of my shaders.

I haven’t seen then code, so I don’t think so. :slight_smile:

I made an attempt using buffers for the 3D Lab, but I must have made some strange mistakes, so it would be interesting to check out some code that works. I’ve only made 2d effects with shaders so far.