General Questions about Module, Storyboard, Organizing Your Project

So I am getting to a point with my little test card game where I would like to start better organizing it into separate lua files. I have a few files now for UI, handling touches, rendering, etc. However, I am using *gasp* global functions and variables. Trust me, I am more disappointed than you are. And I am going to fix it.

Unfortunately I am stuck in a position where I have just finished a number of “make this little game in under an hour” type tutorials, and a lot of the intermediate tutorials are beyond my understanding. I did find this one (http://www.coronalabs.com/blog/2011/07/06/using-external-modules-in-corona/) which was very much at my level, but it was also short and pretty old (based on what I recall reading sporadically, the old methods for using modules are considered improper today). So if anyone can answer one or a few of the following questions I would be incredibly thankful.

1. Do you know of any beginner level tutorials on modules, storyboard, and similar topics that are up to date?

2. What is the popular opinion on modules these days? Are they still used or has something similar replaced them?

3.  If they are still used, is it still basically just:

[lua]

module(…, package.seeall)

[/lua]

in the module file and

[lua]

local example = require( “example” )
local helloWorld = example.helloWorld

[/lua]

in the file using said module? Or is this considered a poor method these days?

4. I’m trying to wrap my head around what exactly storyboard is. My vague understanding of it is that it is API that helps you manage different scenes in the game (such as different levels, but perhaps also useful for menus and so on). Is this something that should be used in pretty much any game, or is it only situationally useful, and if so how?

Thank you very much for your time!

what i do is

module:

local newModule = {}    newModule.init = function( ... )       some code here    end   return newModule

main:

local myModule = require'newModule' myModule.init( some args here )

now there are other ways that are more proper but this is the easiest i think

anyway for a complete example of this you can download one of my modules from the code exchange

as far as number 4 you are correct it can be used for menus and all. i would say its the most common now although some still use director which is used for the same thing. it doesnt have to always be used but in most cases you would

I’ve done a bit more searching and reading and for those stumbling upon this thread I would strongly recommend reading the following: http://www.coronalabs.com/blog/2012/08/28/how-external-modules-work-in-corona/

In fact the previous one I linked was just removed - I’m guessing a mod saw it and decided to remove it due to it being obsolete.

I also found this which very briefly explains storyboards: http://www.coronalabs.com/blog/2012/08/21/storyboard-basic-usage/

I do wish it gave a better overview of storyboard’s purpose and some core features which I assume a lot of people familiar with Director Cass would know (it seems very much targeted at people who already are familiar with Director Class, which I am not). Still, it was helpful to get started - I will have to delve into testing it a bit before I can figure out how far I can get with just this information. If anyone knows of any good beginner overviews for storyboard that are more thorough (but not overly technical) please post it here!

@jstrahan

Thanks for the input! This corroborates what I saw in the newer article linked above. I’ve noticed, like you also refrained from, they didn’t declare the function local.

[lua]

t.hello = function()
print( “Hello World.” )
end

[/lua]

Is that not necessary because of the manner in which it is declared, as belonging to this table/module? I’m assuming these aren’t becoming global.

in my example in the module newModule is local newModule.init is local cause of newModule being local

in main myModule is local so myModule.init is local

think of it all as tables which is what all this really is, you only declare the table as local not all the table entries

@jstrahan

That explanation about scope was very helpful, thanks again!

Still playing around with some classes I am working on and storyboard - will report back if something interesting happens.

welcome

what i do is

module:

local newModule = {}    newModule.init = function( ... )       some code here    end   return newModule

main:

local myModule = require'newModule' myModule.init( some args here )

now there are other ways that are more proper but this is the easiest i think

anyway for a complete example of this you can download one of my modules from the code exchange

as far as number 4 you are correct it can be used for menus and all. i would say its the most common now although some still use director which is used for the same thing. it doesnt have to always be used but in most cases you would

I’ve done a bit more searching and reading and for those stumbling upon this thread I would strongly recommend reading the following: http://www.coronalabs.com/blog/2012/08/28/how-external-modules-work-in-corona/

In fact the previous one I linked was just removed - I’m guessing a mod saw it and decided to remove it due to it being obsolete.

I also found this which very briefly explains storyboards: http://www.coronalabs.com/blog/2012/08/21/storyboard-basic-usage/

I do wish it gave a better overview of storyboard’s purpose and some core features which I assume a lot of people familiar with Director Cass would know (it seems very much targeted at people who already are familiar with Director Class, which I am not). Still, it was helpful to get started - I will have to delve into testing it a bit before I can figure out how far I can get with just this information. If anyone knows of any good beginner overviews for storyboard that are more thorough (but not overly technical) please post it here!

@jstrahan

Thanks for the input! This corroborates what I saw in the newer article linked above. I’ve noticed, like you also refrained from, they didn’t declare the function local.

[lua]

t.hello = function()
print( “Hello World.” )
end

[/lua]

Is that not necessary because of the manner in which it is declared, as belonging to this table/module? I’m assuming these aren’t becoming global.

in my example in the module newModule is local newModule.init is local cause of newModule being local

in main myModule is local so myModule.init is local

think of it all as tables which is what all this really is, you only declare the table as local not all the table entries

@jstrahan

That explanation about scope was very helpful, thanks again!

Still playing around with some classes I am working on and storyboard - will report back if something interesting happens.

welcome