Codea tutorial

I made a start at putting a tutorial on the wiki: As it’s a wiki, make it better.

@Andrew_Stacey very nice tut

I guess a priority would be to cover the codea/codify functions that are not plain Lua like ellipse.

At some point we could circle back and convert the plain Lua tutorials from command line to codea/codify.

My question there would be things like type() which work in codea/codify but are not explicitly documented. Can we just assume that if it works it is supported? Also, we’d have to skip things not currently supported like io.

But that can wait until the codea/codify unique items are covered.

Yes, I triple posted.

And, yes, some of the wiki conversation has leaked to here.

But, here is another piece of tutorial:

We may want to push “Tutorial” up to the TOC and have “Getting Started” as the top entry there. While “Parameter” depends on “Getting Started”, not everthing that follows has to be strictly one after another. We can let them skip around to what they want to learn about.

@Ipda41001 i wrote the codea getting started guide that you referenced to, i will be happy to contribute more to the community. I am also working on small Codea that i will open source it soon.

@Falnatsha is your preference to expand on your site or in the wiki. My instinct at the time was to copy it to the wiki but didn’t want to without checking first. In the mean time @Andrew_Stacey put up a start. I wish we had more people speaking up on what they may want added/need for themselves.

I’d prefer it if tutorials were developed on the wiki. I think the collaborative nature means that the tutorials will end up better and having them all in one place will help new users.

As Ipda said, I made a start on a couple and also came up with a list of what felt like good beginner tutorials.

Andrew - the tutorials are invaluable; awesome contribution! Thank you!
A heads up: the link to tut 3, “”, at least on my iPad, does not return a tutorial page.

That’s because no-one’s written it yet! I put up a list of tutorials that I thought would make sense to have written, but not all have been written yet (and unfortunately, this wiki software doesn’t show the difference between existing and non-existing pages).

Also, although I’ve made a start on the tutorials, they don’t have to be written by me. Anyone else should feel free to write one too.

I thank you all for this discussion thread to begin with - I have been madly searching for something or someone who could explain what everything means during tutorial, from definition of terminology to the the most basic concepts. It has been super hard to find that sort of thing. I had only ever learned basic, a billion years ago, and html in the mid 90s. Thank you, gebloom and ipad41001, for voicing the concerns of those of us who have enough knowledge to know there’s crazy stuff going on, but not enough to know that we don’t need to care.

As a result of finding THIS discussion thread, I went to the link Andrew put of of his tutorials, .

This was EXACTLY WHAT I HAD BEEN LOOKING FOR!!! Thanks, Andrew!! It’s been super helpful to me and, I am sure, many others trying to learn to use Codea and to understand Lua. I’ve been working on a project for a class and I finally feel like I can at least BEGIN to understand what’s going on! MUCH APPRECIATED! I know others in my class were having similar problems, so I’ll be sending them here as well.

Hi @ejude83 - there are also some tutorials over at

Hi, I’m a newcomer to Codea, although an experienced programmer in everything from FORTRAN to Powerbuilder and VB. I’m finding Reefwing’s tutorials helpful in figuring how to make Codea do stuff. I recently did his tutorial 2 “Rounded Rectangles” successfully, but I’m puzzled by the function vec2, which I find here and there in other drawing examples as well. It isn’t listed in either the Codea reference or the Lua reference, but doesn’t appear to be local to any sample classes either. Where is this defined and what exactly is it doing? Something to do with a radius around a given point, but what? Also, are there any standard functions for drawing shapes other than rectangles? I don’t want to make a lot of extra work for myself.

This is sort of simplified, but vec2 is basically a point in 2d space, so it has an x and a y coordinate. So if you say:

p = vec2(50,50)

That basically translates to “p is a point located at 50,50 on the x,y coordinate plane.”

Hi @NancyW - glad you liked the tutes. Vec2 is defined in the Codea Reference. Have a look at:

Yes there are standard functions to draw simple shapes. Have a look at:

Hi, Reefwing. Thanks for your response. Yes, I discovered I hadn’t scrolled down far enough to see all the documentation. However, as for simple shapes, it appears we have rectangles, circles, and lines. I’ve successfully created a triangle and written code to change its dimensions using parameters and to drag it around by touch, so so far so good. But I was disappointed to see that fill only works on rectangles and circles. My triangle can’t be filled. is there a method for this?

Also, I don’t know if it’s a Codea bug or something I’m doing wrong: I imported an image from my photo library and loaded it into a sprite for display. It displays okay, but after about 10 seconds, Codea just exits while the project is running. Should I report this, or have I done something dumb?

It is probably larger than 2048 x 1536 pixels, which is the max image size in Codea.

@NancyW are you perhaps re-loading the image every frame? Are you loading your image in the setup() function, or in the draw() function? If in the draw() function, it might be getting loaded over and over again, leading your iPad to run out of memory.

Thanks. I tried moving the image load to setup, but I moved the sprite call as well and it didn’t work. I’ll just move the image load and very likely that should fix it.

About a year I use Codea. It is a very nice programming tool for the iPad. I am using it specially for calculations, together with the graphical functions you can make good looking programs with selection buttons, pop-up windows, graphs, etc.
As a newbie you must learn how Codea works, you must learn the Lua instructions and make test programs. I think there is enough information inside the Codea Reference, the Wiki, the Forum and the Lua Manual. The information on “Getting Started”

My question: (sorry for the long intro)
As a newbie you are thinking that the Lua instructions mentioned in the Codea Reference are all the Lua instructions which are used in Codea, but that is not true!
Simeon, can you make a simple list which Lua instructions are implemented in Codea?
For me it is like a puzzle!
Maybe better to implement this inside the Codea Reference, next update?


"So heres my real confusion, im just not use to the constant repeating of the draw() function. "

The draw() loop. is just like the main loop in old c programming. Just think of it as a loop that is constantly running I know you are used to using a call method for making the screen update. well here is a tip while you were making method calls to perform a screen update what that did under the hood was perform a frame buffer flip. the screen is being contently updated anyways. They just remove you from dealing with that code and just let you draw to the FB and then when you do an update it flips to the buffer you were drawing to. in the structural programming days with C we had to perform this flip ourselves. But we typically would write a handler that would do it for us and worry about drawing to a FB and then calling a for a flip when needed.

Not sure if I can explain it any better than I have. But I’m sure you get the concept. The bottom line is that you should use the draw function put in calls to your handlers like checking for button presses or updating the screen. you may just instantiate two different classes in the draw() loop and run them every cycle and do all of the other coding externally from the draw() loop. I can see how dumping 1500 lines into one loop would lead to problems.