lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2012/1/16 Ezequiel García <>:
> 2012/1/16, Francisco Sant'anna <>:
>> If I got it right, I think you can also change the Canvas initialization:
>> -- local Canvas = {}
>> local Canvas = _M
> Why? (with a head scratching picture)

You are trying to mix two ways of making a module. One is to just
return at the end whatever the module should be (a new canvas), the
other is to use the module() function. Its confusing, and doesn't

module() creates a table to be your "module", makes it the environment
(so any "global" definitions go into it magically), and also arranges
for _M to be defined as that table so you can access it.

I don't think you should be calling module(), but you might be able to
make _M "be" the base canvas, and not return anything.