Extending an Application with Lua Plugins

Introduction A very common use of the Lua language (which is a very versatile) is using Lua to extend an application via plugins. Many popular games use Lua for this very purpose. Adding a plugin framework to an existing application is trivial with Lua. Also, Lua provides a very capable and easy to use language for writing plugins. To demonstrate using Lua for plugins I’m going to make very basic text editor and allow features to be added via Lua scripts (user installable plugins)....

August 16, 2014 · John

Using Lua as a Templating Engine

Introduction There are a lot of templating engines to choose from. The vast majority of which are primarily geared toward the web. Meaning they’re specially designed for outputting HTML/XML documents. Lua provides more flexibility and can easily be used as a general templating engine. Also, Lua is very easy to embed and use from a C application. Lua being flexible and easily embeddable means that it can be used to extend a program in a variety of ways....

August 6, 2014 · John

Wrapping a Lua module in C

Introduction So far I’ve covered wrapping a C library in Lua, writing a Lua module, and calling Lua from C. The next step is using this knowledge to wrap a Lua module in C. Basically, the opposite of wrapping a C library in Lua for use in Lua. In this case we want the library written in Lua and used by C. Essentially, this is an extension of what was covered in “Calling Lua From C”....

August 2, 2014 · John

Calling Lua From C

Introduction One very useful feature of Lua is how easy it is to work with from C. Unlike other scripting languages Lua’s C support goes to and from. Meaning you not only can call C from Lua but you can call Lua from C. Often you’ll see applications written in a high level language with specific functionally written in C. Typically this is performance critical code where the optimization is using C instead of the high level language....

July 26, 2014 · John

Wrapping a C library in Lua

Introduction An often overlooked feature of Lua is the C API. The most common use I’ve seen is to allow Lua scripts to use existing C libraries instead of reimplementing existing functionality in pure Lua (which is not always feasible). Fortunately, Lua has very strong integration with C and while not trivial, wrapping a C library is fairly straight foreword. That said Lua’s C API isn’t specific to this task, it’s just a common use of the C API....

July 12, 2014 · John