LuaD is a bridge between the D and Lua programming languages. Unlike many other libraries built on the Lua C API, LuaD doesn't expose the Lua stack - instead, it has wrappers for references to Lua objects, and supports seamlessly and directly converting any D type into a Lua type and vice versa.
See luad.state.LuaState to get started.
import luad.all; void main() { auto lua = new LuaState; lua.openLibs(); lua.doString(`print("Hello, world!")`); }Another "Hello, world"
import luad.all; void main() { auto lua = new LuaState; lua.openLibs(); //LuaState also works as an alias for the global table auto print = lua.get!LuaFunction("print"); print("Hello, world!"); }Simple function example
import luad.all; import std.stdio; int printTimes(int times, const(char)[] message) { for(int i = 0; i <= times; i++) writeln(message); return times; } void main() { auto lua = new LuaState; lua["printTimes"] = &printTimes; lua.doString(` printTimes(3, "hello, world!") `); }Configuration file
import luad.all; struct Config { string Name; double Version; } string configFile = ` Name = "foo" Version = 1.23 `; void main() { auto lua = new LuaState; lua.doString(configFile); auto config = lua.globals.toStruct!Config(); assert(config.Name == "foo"); assert(config.Version == 1.23); }