What is it?

XNua is a implemtation of Lua for XNA. The normal approach of compiling the Lua source code under C doesn't work under XNA for 360 as we have no way (yet) of running unmanaged/unsafe code on the console.

However a few years ago, a project called Lua2IL was made that could convert Lua 5.0 byte code into CLR IL and then interact with the .Net (CLR) runtime. As a research project it seems to have achieved its aim of proving that it could be done and then seemingly stopped any progress. All efforts were put into LuaInterface which uses a unmanaged DLL to interface Lua under c#. Even the website to Lua2IL seemed to have disappeared.

When XNA appeared, I became interesting in getting Lua running on the 360 for several reasons. The first is I use Lua for much of my game entity customisation and loading on my C++ game engines and like it a lot. The second equally important is Lua is now almost a games industry standard script langauge, its extremely easy to add to projects on many platforms (Its certainly shipped on most modern consoles including PSP, PS2, PS3, Xbox, Xbox360 (native)). We use it on Heavenly Sword and if you wanna be a games designer these days knowing your way around a Lua script is fairly important.

XNua is unusual compared to standard Lua in that the runtime side of it, doesn't have a parser. The parser and compiler are contained on the host PC as a content pipeline, which the C# runtime providing the most of the standard Lua library. This means fairly standard lua paradigms such as DoString don't work as you would expect. As the Garbage Collection is not the standard lua one but the .NET CLR one.

Its for this reason (and that its incompatiable with Lua2IL at the binary level) that I renamed it XNua, it is Lua 5.0 but you can't expect it to all run all Lua 5.0 scripts. Its a good solution for Lua on 360, as you have to use GSE to deploy files to the X360 anyway, so running a compiler first isn't a problem. However on PC if you need to dynamically compile scripts tradional Lua (via LuaInterface) may be a better choice.

I suspect that with a small change to the Lua compiler stage (currently is uses the XNA content pipeline but a indepdent compiler wouldn't need this dependency), this will also work on any .Net 2.0 Compact device. So if you would benefit with Lua for mobile devices, this is probably a good place to start.

In the end, the point is that the Lua language is available on almost any game platform you can name, so its a really good place to build your entity and gameplay customisation model on :D


Posted on Sun, 2007-03-04 15:02 by deano
» login or register to post comments