lua-users home
lua-l archive

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



Hi all,

I found a workaround for the problem we had. It is placed in the module code:

>> -- Starts here
>> module(..., package.seeall)
>>
>> description =3D 'Module description'
>> -- Ends here


The problem is in the "..." string. The loadstring () operator tries to load it as a string and it fails, because "..." it is *not* a valid string.

Instead of that, what I now load the module in a lua string and do a substitution: instead of "...", the string "module_name" (which the corresponding module name, "defs" in my previous example ) is used.

It is also the correct approach, because in this way, lua states can match the module loaded with loadstring () with a package in the state.

Therefore, it goes:
TCP client request a module from Server
Server sends the module as string
Client substitues the string '...' by 'module name'
Client calls loadstring (module_content).

All lua scripts can now use the module got from the far-end

Regards,
José