Compiling Lua

From Blue Mars Developer Guidebook

Jump to: navigation, search



Lua scripts are compiled at runtime, but you have the option to precompile your scripts, using the LuaCompiler executable in the bin32 directory,

Instead of ending with .lua, compiled lua scripts by convention end with .luac.


To compile a Lua script:

  1. Start the Command Prompt
  2. cd to the directory containing your script
  3. invoke "Bin32/LuaCompiler -s -o myscript.luac myscript.lua" (substituting your script filename and prepending the necessary number of "..\" to the Bin32 path
  4. adjust any references to your script to refer to the .luac version - modify any relevant calls of Script/ReloadScript and the corresponding .ent files of compiled Entity Scripts


Invoking LuaCompiler without any arguments will display a list of the available options.

luacompiler: no input files given
usage: luacompiler [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


Note that the compiler compiles to bytecodes, not machine code.

LuaCompiler is a custom version of the standard luac compiler. Standard luac will not work for Blue Mars scripts.

There is a version of LuaCompiler in the Bin64 directory also, but don't use it - that version doesn't produce code that can be loaded by Blue Mars.

Precompilation should only take place after you've finalized your script development, in particular, after Lua Debugging

Precompilation is only available in builds later than 5/15/2009.

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools