Specify error handling scheme for LuaState.doString and LuaState.doFile.
Represents a Lua state instance.
Create a new, empty Lua state. The standard library is not loaded.
If an uncaught error for any operation on this state causes a Lua panic for the underlying state, an exception of type luad.error.LuaErrorException is thrown.
Create a D wrapper for an existing Lua state.
The new LuaState object does not assume ownership of the state.
lua_State* L | state to wrap |
The underlying lua_State pointer for interfacing with C.
Get the LuaState instance for a Lua state.
lua_State* L | Lua state |
Open the standard library.
The global table for this instance.
The registry table for this instance.
Set a new panic handler.
void function(LuaState, in char[]) onPanic | new panic handler |
auto L = luaL_newstate(); // found in luad.c.all auto lua = new LuaState(L); static void panic(LuaState lua, in char[] error) { throw new LuaErrorException(error.idup); } lua.setPanicHandler(&panic);
Compile a string of Lua code.
char[] code | code to compile |
Compile a file of Lua code.
char[] path | path to file |
Execute a string of Lua code.
char[] code | code to run |
LuaErrorHandler handler | error handling scheme |
Execute a file of Lua code.
char[] path | path to file |
LuaErrorHandler handler | error handling scheme |
Create a new, empty table.
Create a new, empty table with pre-allocated space for members.
uint narr | number of pre-allocated array slots |
uint nrec | number of pre-allocated non-array slots |
Create a new table from an InputRange. If the element type of the range is Tuple!(T, U), then each element makes up a key-value pair, where T is the key and U is the value of the pair. For any other element type T, a table with sequential numeric keys is created (an array).
Range range | InputRange of key-value pairs or elements |
Wrap a D value in a Lua reference.
Note that using this method is only necessary in certain situations, such as when you want to act on the reference before fully exposing it to Lua.
T | type of reference. Must be LuaObject, LuaTable, LuaFunction or LuaDynamic. Defaults to LuaObject. |
U value | D value to wrap |
Register a D class or struct with Lua.
This method exposes a type's constructors and static interface to Lua.
T | class or struct to register |
Same as calling globals.get with the same arguments.
Same as calling globals.get!LuaObject with the same arguments.
Same as calling globals.set with the same arguments.
Same as calling globals.opIndexAssign with the same arguments.