lua-users home
lua-l archive

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




On Wed, Nov 12, 2014 at 10:09 PM, Rena <hyperhacker@gmail.com> wrote:
On Wed, Nov 12, 2014 at 10: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() is for doing the opposite. Just do:

f = load("print('hello')")
f()

load() compiles Lua source and returns a function. string.dump() takes
a function and returns a binary string that can later be given to
load().

--
Sent from my Game Boy.


Seems like that should be "string.load()" then, doesn't it? That is, string.dump and string.load would be symmetrical.

-Andrew