lua-users home
lua-l archive

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


Hello,

string.dump() is the right function. However, it will not strip the debugging information. At least not until Lua 5.3, where you can specify this as optional parameter. The debugging information is what you see as 'source text'.

Possibly you could try to use the output of the standalone Lua compiler luac as input for load().

--
Oliver

Am 13.11.2014 um 06:45 schrieb Tim Hill:
On Nov 12, 2014, at 7:33 PM, Milind Gupta <milind.gupta@gmail.com> wrote:

Hi,
         I have a lua script which has some scripts written inside string variables. Is it possible to have these scripts as compiled scripts so when I compile the main script using luac these scripts are not visible directly as text in the compiled file?
        I tried to have the strings as string.dump(load(scriptAsString)) but that still has the text of the script although I see some binary characters appended.

Thanks,
Milind


string.dump() will just give you the byte codes, not the source code. Are you sure about your code? And yes, once you have the byte code you can use it as input to load() to avoid having the source code distributed. Note, however, that byte code is NOT portable and so may not load if the target platform differs from the one on which it was compiled.

—Tim