Lua Design Patterns / Structuring

Hello,

as I am towards finishing my first little project in Corona SDK, I wondered how i would build larger projects with it. I programmed mostly in OOP-languages (In my case Java) and know very little about scripting languages. I read about some lua lib with OOP integration. Are they good? Or what are possible design patterns for medium/larger projects in Lua? I thought about using factory like modules as I know them from OOP-programming and component based entities as they would fit well with the table structure thing, I guess. But I’m not sure about it at all. What are common approaches to structure a medium/large sized project in Lua?

Greeting Dominik

Depends on the type of project.

I found it simpler to not use an OOP-framework at all, and instead program my own simpler version: each screen object (an enemy or a player etc…) is defined as a prototype, and other instances are created from this prototype by setting their metatable to the original object.

Two things:

  1. At first this is very complicated. Then, once you get it, it is super-simple.

  2. The metatable syntax is, however pretty illegible to me, but that’s okay because I only need to copy this from some tutorial code-block once.

  3. I don’t even know how to structure this stuff anymore, but I have my “prototypes” that work, and I just copy new stuff off of these.

Cheers,

Thomas

p.s. Are you up to speed on using metatables? This concept is brilliant in it’s simplicity in Lua (and it’s sort of pseudo-OOP).

Depends on the type of project.

I found it simpler to not use an OOP-framework at all, and instead program my own simpler version: each screen object (an enemy or a player etc…) is defined as a prototype, and other instances are created from this prototype by setting their metatable to the original object.

Two things:

  1. At first this is very complicated. Then, once you get it, it is super-simple.

  2. The metatable syntax is, however pretty illegible to me, but that’s okay because I only need to copy this from some tutorial code-block once.

  3. I don’t even know how to structure this stuff anymore, but I have my “prototypes” that work, and I just copy new stuff off of these.

Cheers,

Thomas

p.s. Are you up to speed on using metatables? This concept is brilliant in it’s simplicity in Lua (and it’s sort of pseudo-OOP).