1
votes

I know it is possible to compile the Lua code using LuaC as described here:

luac is the Lua compiler. It translates programs written in the Lua programming language into binary files that can be loaded and executed with lua_dofile in C or with dofile in Lua.

The problem is: I need to create an application in .Net (more specifically in C#) that will receive an input of multiple 'regular' *.lua files and then compile all of them to new files.

2
That's a link to very old lua documentation for the record. Are you asking how to do what luac does in your own code? Have you tried looking at the luac source? - Etan Reisner
I'm wondering if is there a library that could do that for me... - Alexandre Severino
Yes, lua. Look at the code for luac. - Etan Reisner

2 Answers

2
votes

loadfile followed by string.dump does essentially what luac does.

0
votes

I ended up having to call LuaC.exe from inside my application.

My solution was doing the following:

string outFile = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + ".out";
System.Diagnostics.Process.Start(System.IO.Directory.GetCurrentDirectory() + "\\luac.exe", "-o \"" + outFile + "\" \"" + path + "\"");

path = outFile;