Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea Tutorials: Tutorial 25 - A Lua Primer for Codea

edited January 2013 in General Posts: 563

Every year around Christmas I notice a surge of activity on the forums as folks get their new iDevices and download Codea. This has prompted a number of common questions on my tutorials, so i thought I would try and fill in some of the gaps with a quick primer on Lua (particularly in the Codea context).

As usual comments and suggestions are very welcome. I plan on covering the Lua libraries in a separate tutorial.

The tutorial is available here:



  • Jmv38Jmv38 Mod
    edited January 2013 Posts: 3,297

    Great tuto! Your style is so clear... I think this tuto is really useful to beginners.
    Some possible precisions:
    - defined variables are accessible only after the line they are declared.
    - You can't concatenate a boolean. When you need to, use tostring() function.
    - comparison operators (== ~= < > <= >=) do not coerce their arguments. When you need to use tonumber() function.
    - you can check the type of myvar by type(myvar).
    - userdata: all special objects defined by Codea api are of type 'userdata'.
    - Try converting the Ship class so that it uses a global variable points instead of self.points.
    - i think it wouldnt harm to say:
    function Ship:hit( damage ) is equivalent to function Ship.hit( self, damage ).
    ship:hit( 20 ) is equivalent to ship.hit( ship, 20 ).
    This helps to understand the error message when you type ship.hit by accident.

  • Posts: 563

    Thanks @Jmv38 - all good comments. I will update the tute accordingly on the weekend.

Sign In or Register to comment.