Using NLua

About NLua

By default, Dialogue System's underlying Lua environment using Lua Interpreter, which is a cross-platform Lua interpreter written in C#.

You can, however, use NLua instead. NLua is written in C++ and interfaces with Unity using Unity 5/Unity 4 Pro's P/Invoke capability. If your project runs large blocks of Lua code, it may run faster in NLua. The Dialogue System itself runs so little Lua code that you generally will not see any performance difference between Lua Interpreter and NLua.

For more information on NLua, see www.nlua.org.

Restrictions

Before switching to NLua, be aware of these restrictions:

  • NLua requires Unity 5+ or Unity 4 Pro.
  • Not all platforms are supported (e.g., not compatible with Windows Store builds).
    • NLua supports: Mac, Windows native applications, Android, and Windows Phone 8.
    • NLua supports iOS only with Mono base builds. Since NLua uses MonoPInvoke, it's not compatible with IL2CPP.

How to Switch to NLua

To switch to NLua, import Third Party Support/NLua Support.unitypackage. You can then delete DLLs/LuaInterpreter.dll if you want to shave a little off of your build size. (Deleting LuaInterpreter.dll is optional.)

NLua Source Code

Optional: If you have unpacked the Dialogue System's source code, you can also unpack the NLua source code in Scripts/NLua Source Code.unitypackage. Do not import this package unless you've unpacked the Dialogue System's source code, too.

To compile the Dialogue System's source code using NLua, define the preprocessor symbol USE_NLUA (Edit > Project Settings > Player -> Scripting Define Symbols).


<< Lua Console | Sequences >>