Module Help new module

Currently im creating my own module, I was successful doing it but, I want to more flexibility in it

right now all I can do is this in the main.lua

local comboB = comboBox.newComboBox(whateverIsInside) comboBox:setBorderColor(whateverIsInside)

my Module is like this :

local M = {} function M.newComboBox(params) --Whatever is inside end function M:setBorderColor(params) --Whatever is Inside end return M

What I want to do is like this in the main.lua

local comboB = comboBox.newComboBox(whateverIsInside) comboB:setBorderColor(whateverisinside) comboB.x = infinity

just like in the display API which looks like this

local text = display.newText("asdasd",100,100,native.font,32) text.x = infinity text:setFillColor(1,0,0)

and I can do this:

print(text.text)

thanks

Many times in modules it is good to do

[lua]local M = display.newGroup()[/lua]

instead of 

[lua]local M = {}[/lua]

since display.newGroup returns a table.

Then you insert all your display object into the M group and you should be able to achieve what you want.

and now I can do this

comboB:setFillColor(1,0,0)

instead of

comboBox:setFillColor(1,0,0)

BTW my objects are all in a function

I stil can’t do it, it says comboB is a nil value

OK, I see. You will need to use metatables then, then you can create multiple objects with your module and control them individually. 

Take a look at this tutorial, I used it when I was learning this stuff: https://www.youtube.com/watch?v=CYxMfVy5W00

Didn’t kno wa thing about metatable and such thing exist, thanks men @jonjonsson

Many times in modules it is good to do

[lua]local M = display.newGroup()[/lua]

instead of 

[lua]local M = {}[/lua]

since display.newGroup returns a table.

Then you insert all your display object into the M group and you should be able to achieve what you want.

and now I can do this

comboB:setFillColor(1,0,0)

instead of

comboBox:setFillColor(1,0,0)

BTW my objects are all in a function

I stil can’t do it, it says comboB is a nil value

OK, I see. You will need to use metatables then, then you can create multiple objects with your module and control them individually. 

Take a look at this tutorial, I used it when I was learning this stuff: https://www.youtube.com/watch?v=CYxMfVy5W00

Didn’t kno wa thing about metatable and such thing exist, thanks men @jonjonsson