1. Home
  2. Computing & Technology
  3. C / C++ / C#
photo of David Bolton
David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

Lua- a Scripting Language for Games

Tuesday December 23, 2008
It's not the best kept secret but the video games industry makes extensive use of scripting languages such as Lua to control game logic, trigger events and speed up development. A powerful programming language in its own right, having Lua in your application adds just 150KB to the size of any executable. It interprets bytecode (like .NET/Java etc). This is an excellent introduction to Lua's use.

Best selling games like Crysis and Far Cry use Lua for scripting. Dialog, game logic etc are all controlled by Lua scripts. If the game logic was coded in C then it would require a longer edit-build-test cycle and script designers who could program in C. With Lua, you just edit the script and save it. I'd imagine the game development system includes the Lua compiler and script changes are much faster to turn round than a full compile and link for C code. It also means that the C code developers can deliver new binary code to the scripting guys and both can work independently of each other. Lua is implemented in 17.000 lines of Ansi C code and I've added a link in the C Code library.

Developed in Brazil (Lua is Portuguese for Moon) in the early 90s, Lua is free software so you can use it royalty free in your software. This is not a toy language, it's more powerful than C in some places with features like closures and coroutines. It doesn't have classes but does have features that let you implement class like code. It's a good fit for C though, not just the implementation but the C API. There are Lua implementations for Windows, Dos, Linux, .NET as well as other programming languages. If you want to learn more about Lua, Wikipedia is a good starting point to Lua.

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.