English lua to luac

8 replies
Goto Page
To the start Previous 1 Next To the start
31.01.17 11:57:03 pm
Up
StrikerD2000
BANNED
Offline Off
is that a way to convert lua to luac ? √
@user StrikerD2000 | I love DC

Admin/mod comment:

Removed needless poll. /Starkkz
01.02.17 12:06:24 am
Up
Starkkz
Moderator
Offline Off
Code:
1
2
3
4
5
6
7
8
inputFileName = "input file.lua"
outputFileName = "output file.lua"

inputFunction = assert( loadfile( inputFileName ) )

outputFile = io.open( outputFileName, "wb" )
outputFile:write( string.dump( inputFunction ) )
outputFile:close()


Simplest way I believe.
lol
01.02.17 06:28:38 am
Up
VADemon
User
Offline Off
Code:
luac(.exe) -o Outputfilename.luac script1.lua script2.lua

Lua binaries has written:
luac:
usage: luac [options] [filenames].
Available options are:
- process stdin
-l list
-o name output to file 'name' (default is "luac.out")
-p parse only
-s strip debug information
-v show version information
-- stop handling options
01.02.17 09:20:44 am
Up
Pagyra
User
Offline Off
All right, and after renaming the *.luac in *.lua CS2D will continue to work with it, so it is one of protection for lua code.
file cs2d Quake 2D Arena (29)'s lua code is protected in same way.
edited 1×, last 01.02.17 10:53:12 am
01.02.17 08:38:40 pm
Up
Fraizeraust
Moderator
Offline Off
luac.mtasa.com

Way faster to compile a Lua file into .luac just within few clicks - doing some researching won't hurt. Unless you want to have all the control over how you compile the file then you have got to implement the Lua compiler yourself and run the command from user VADemon's post above.
06.02.17 03:31:37 pm
Up
MikuAuahDark
User
Offline Off
The only reliable lua compiler which is compatible with CS2D is
luac(.exe)
method posted by user VADemon. MTASA LuaC gives me bad header in precompiled chunk (you must select no obfuscation, as it will gives invalid lua precompiled header)

string.dump()
(user Starkkz approach) (and actually user VADemon command-line) preserves the debug information, which in turn can be unluac'd easily. However, using
luac -s -o <output> <input>
would destructively compile it (notice the
-s
argument which tell luac to strip debug information).

EDIT: Also you need to use 32-bit LuaC! 64-bit LuaC will lead to incompatibility because Lua bytecode depends on architecture (integer size)
edited 1×, last 09.02.17 02:32:57 pm
file cs2d LuaJIT for Dedicated Server (9) JIT POWER! | Know your Lua errors! | don't use PM for scripting help!
06.02.17 07:20:53 pm
Up
Starkkz
Moderator
Offline Off
@user MikuAuahDark: Pretty constructive answer, I've been looking for that information but I thought that luac'd code could always be unluac'd.
lol
07.02.17 10:18:21 am
Up
MikuAuahDark
User
Offline Off
Actually even with that approach, the compiled code still can be unluac'd, but at least it will make it harder to reverse engineer.
file cs2d LuaJIT for Dedicated Server (9) JIT POWER! | Know your Lua errors! | don't use PM for scripting help!
To the start Previous 1 Next To the start