[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua scripts as string within another script
- From: Paul K <paul@...>
- Date: Thu, 13 Nov 2014 07:09:59 +0000
Hi Milind,
> 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?
Just to make sure I understand what you are trying to do. You have a
script A, which you a compiling to bytecode, but you also have scripts
B and C embedded into A and you don't want the users to see B and C in
the compiled code?
If so, you can write a function that turns them into something else,
for example, set of numbers. This may look like this:
decode("my string I don't want to see")
and decode function checks if it gets a string, it simply returns it,
but if it gets an array, it converts the content of that array into a
string and returns it.
Then you write a pre-processor that finds all instances of
decode('some string') and convert them into something like
decode({f('s'), f('o'), f('m')....}), where f() is some function that
converts a character into a different form, for example, a number.
This is simple enough to not have a significant performance impact and
good enough to make messages not visible in the binary code. Usual
disclaimers about dedicated hackers apply...
Note that the bytecode Lua generates is platform-dependent (this is
not the case for LuaJIT, which generates version-dependent, but
platform independent bytecode).
Paul.