Lua Metatables and OOP for dummies (i.e. Me)

Hello!
Despite having read several resources including the official Lua documentation (PIL, etc) about Metatables and OOP in Lua, I still have a difficult time understanding these concepts.

For example - I am looking at the following code on http://lua-users.org/wiki/LuaClassesWithMetatable:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Lua 5.0.3  Copyright (C) 1994-2006 Tecgraf, PUC-Rio
> t = { 11, 22, 33, you='one', me='two' }
> mt = { __index = print }
> = t.you 
one
> = t.fred
nil
> setmetatable(t, mt)
> x = t.fred
table: 0x8075e80        fred
> = x
nil
> = t
table: 0x8075e80
> 

Right after I posted the above question, I came across a very useful series of Corona SDK tutorials by Dr. Rafael Hernandez on YouTube.

In particular, I found this tutorial on how to create Corona SDK Modules very useful. It is pointing me in the right direction with my project.

Wanted to share with the rest of you in case you haven't seen it:

Corona SDK 08: External Modules by Dr. Rafael Hernandez
http://www.youtube.com/watch?v=WX1Swovbhms

A great video!! Thanks for share with us! :)

You might also want to read this great inheritance tutorial posted by Crawl Space Games:

http://www.crawlspacegames.com/blog/inheritance-in-lua/

views:1749 update:2011/10/5 21:23:48
corona forums © 2003-2011