lua-users home
lua-l archive

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


Hi Мельниченко Пётр,

I was going to try your suggestion and Thijs Schreijer provided me a simpler solution.

Thank you very much!

Sincerely
Journeyer

----------------------------------------
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l  d o t  c o m
----------------------------------------


2014-03-06 17:26 GMT+09:00 Мельниченко Пётр <petjamelnik@yandex.ru>:
> What I imported by require is from the url below.
> http://lua-users.org/wiki/TemplatePattern
> The account.lua.
>
> And I have no idea then...

Oh, the good old module.

In both Lua 5.1[1] and Lua 5.2[2] module("foo") tries to use a global variable "foo" as the module table. And it sets it if it can't find it. So, you'll have to either rewrite the module to not use module() or delete global `account` variable before requiring the module the second time.

[1] http://www.lua.org/source/5.1/loadlib.c.html#ll_module ->
     /* try global variable (and create one if it does not exist) */
[2] http://www.lua.org/source/5.2/loadlib.c.html#ll_module ->
     http://www.lua.org/source/5.2/lauxlib.c.html#luaL_pushmodule ->
     /* try global variable (and create one if it does not exist) */