external module - table inside a function implementation - calling and cleanup REDUX

I am coming to terms with the whole external module thingy.
and I was just wondering am I totally bastardizing the last function ?
I created a table in the last function helloWorld3 inside of the external module(example.lua)
that I want to pass back to the main,lua.

I did it, but the way I did is kindof funky looking.
See the below assignment ---> local "abc"

My question is, Should I be using a different syntax for this "call"
and how would the proper cleanup/garbage collection ? abc = nil

OK, here is the main.lua code

1
2
3
4
5
6
7
8
9
10
11
12
13
-- main.lua
local example = require( "example" )
 
local hel = example.helloWorld
hel()  -- output
print(type(hel))
 
local lo = example.helloWorld2
lo()  -- output
print(type(lo))
 
local abc = example.helloWorld3
print(abc()[1] )

Posting code within  and tags would make it easier to read!

You mean "< lua >" and ""

c

Yeah <lua> and </lua> tags!
My Bad! :)

code updated

Your assigment and call are good.. Regarding your external modules, i would suggest you take a look at this
http://blog.anscamobile.com/2011/09/a-better-approach-to-external-modules/

So your example.lua will be something like

1
2
3
4
5
6
7
8
9
local function helloWorld()
        print( "Hello" )
end
 
local function helloWorld2()
        print( "World" )
end
 
return {helloWorld,helloWorld2}

thanks !! sorry but no matter how much I read the "programming in lua" manual
I cant really understand it. but when I see the code, and I enter it, It seems to stick
in my head. thanks.

i do wanna understand the specifics and make "lean" code with little to no overhead.

thanks satheesh

views:1529 update:2011/12/31 9:35:10
corona forums © 2003-2011