1

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.

Alexandre Severino
  • 1,563
  • 1
  • 16
  • 38

2 Answers2

2

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

lhf
  • 70,581
  • 9
  • 108
  • 149
0

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;
Alexandre Severino
  • 1,563
  • 1
  • 16
  • 38