Multiple lua files in one project

I am trying to learn how to modularize lua by making multiple lua files.  As a C coder, I loved modularizing.

I looked at this program…

http://code.tutsplus.com/tutorials/create-a-balance-ping-pong-game–mobile-20984

I was able to create a file called move_paddle and move that function to another file.

However, when I tried to do that with show credits I was not able to.  I guess I don’t understand the : notation and what that means when modularizing.  I want to try this but can someone give me an example or give me some tips.

Thanks!

To access lua modules that reside in separate lua files, you need to “require” them. In your example, you have a function move_paddle defined in its own lua file, perhaps move_paddle.lua. To use that function in main.lua, or any other lua file, you need the notation:

local move\_paddle = require("move\_paddle")

To me, game credits don’t really belong in a separate module, they belong in a new scene. Corona’s scene_management API is called Composer. Look into that:

http://docs.coronalabs.com/api/library/composer/index.html

To access lua modules that reside in separate lua files, you need to “require” them. In your example, you have a function move_paddle defined in its own lua file, perhaps move_paddle.lua. To use that function in main.lua, or any other lua file, you need the notation:

local move\_paddle = require("move\_paddle")

To me, game credits don’t really belong in a separate module, they belong in a new scene. Corona’s scene_management API is called Composer. Look into that:

http://docs.coronalabs.com/api/library/composer/index.html