I don't understand the Tutorial

Hi, I’m new in lua/codea programming but I now bases of other programming languages.
So I tried to learn with this tutorial : http://codeatuts.blogspot.com.au/ but at the second part of the tutorial, I don’t understand .
He asked us to copy and paste a part of code and then he is explaining it but I don’t understand.
I’ll copy this code and write with comments what I don’t understand :


function roundRect(x,y,w,h,r)
    pushStyle()
    -- until there, I understand all
    insetPos = vec2(x+r,y+r)
    insetSize = vec2(w-2*r,h-2*r)
    -- I don't now why and how use vec2
    --Copy fill into stroke
    local red,green,blue,a = fill()
    stroke(red,green,blue,a)
    -- what is stroke ? And he don't explain what's a local variable ?
    noSmooth()
    rectMode(CORNER)
    rect(insetPos.x,insetPos.y,insetSize.x,insetSize.y)
    -- what's the function rectMode ?
    if r > 0 then
        smooth()
        lineCapMode(ROUND)
        strokeWidth(r*2)

        line(insetPos.x, insetPos.y, 
             insetPos.x + insetSize.x, insetPos.y)
        line(insetPos.x, insetPos.y,
             insetPos.x, insetPos.y + insetSize.y)
        line(insetPos.x, insetPos.y + insetSize.y,
             insetPos.x + insetSize.x, insetPos.y + insetSize.y)
        line(insetPos.x + insetSize.x, insetPos.y,
             insetPos.x + insetSize.x, insetPos.y + insetSize.y)            
         -- I don't understand what are these functions line, how and why use them .
    end
    popStyle()
end

So, thank you very much to explain me this code.

I’ll use this discussion to asks questions about this tutorial if I don’t understand other parts of it .

PS : Sorry if my English isn’t perfect, I’m French .

I do not know what is available in French, but the Lua version 5.0 manual in English will help you understand global variables and local variables in Lua.

The rest of your questions are about parts of Codea, not parts of Lua. Have you read the entries in the Codea in-app reference? If you have not, that is a good place to start.

vec2() is a function that returns a value that represents a two-dimensional vector or, equivalently, a point in two-dimensional space (x, y).

stroke() is a function that sets the colour that will be used to draw lines. Colours are represented by four numbers: red component, green component, blue component and opacity (referred to as ‘alpha’).

rectMode() is a function that sets how the rect() function will interpret its four arguments - the ‘mode’ of the rect() function. rect() draws a rectangle.

line() is a function that draws a line between two points.

That probably does not answer everything you want to know, but may be a first step.

Hi @eloi67 and welcome to Codea. As the tutorials author I may have been guilty of assuming too much knowledge.

I’m just doing a tute on getting your App approved in the App store. Once I’m done with that I will go back and do some tutorials on some of the basics. In the meantime, as @mpilgrem suggests, the Codea Reference docs (http://twolivesleft.com/Codea/Reference/#home/index) has most of what you are after.

Your English is much better than my French!

Thank you for all your answers. I’ll read the lua tutorial and the codea reference.