d-SEAMS: Lua Function Documentation (original) (raw)

In the functions.lua file, lua functions are called, which are registered on the C++ side to inferface with the C++ functions. Here, we document the lua functions currently available to the user.

Currently Registered Lua Functions

The workflows for quasi-two-dimensional ice, quasi-one-dimensional ice and bulk systems are separated. The Lua functions for each work-flow are registered in different blocks in the C++ code.

Common Functions

The following Lua functions interface to the same C++ functions in every work-flow code block.

Quasi-Two-Dimensional Ice

Quasi-One-Dimensional Ice

Bulk Systems

Extending d-SEAMS

d-SEAMS can be extended by writing C++ functions in pre-existing header files or by creating header files of your own.

Registering Lua Functions

In order to call a C++ function from the Lua script, the corresponding Lua function must be registered. This can be done simply in the main.cpp file:

lua.set_function("luaFuncName", cppFuncName);

where luaFuncName is the name of the lua function and cppFuncName is the name of the corresponding C++ function. It should be noted that default arguments must be provided explicitly when the luaFuncName function is called on the Lua side, or else the program will break with an error.

Passing Variables to Lua

If a C++ struct or variable is to be defined or passed to the Lua side, then the variable must be defined using the following syntax inside main.cpp :

lua["luaStruct"] = &cppStruct;

lua["luaVecOfVectors"] = &cppVecOfVectors;

lua["luaString"] = myString;

C++ structs, vectors of vectors and other objects must be passed by reference. This need not be done for strings.