In order to write a proper plugin that will work for MicroMacro, you must follow these specifications.
- Uses the same version of Lua that MicroMacro uses (currently 5.1)
Your DLL must have an install function with these properties:- Is declared as: __declspec(dllexport) int __cdecl install(lua_State *)
The function name must be "install", and is case-sensitive.
Returns 0 on success, non-zero on error.
Registers all Lua functions you will be plugging in to the specified Lua state. (see lua_register());
Is exported as C (to prevent C++ name-mangling) if you are using C++.
- Is declared as: int MyFunctionName(lua_State *)
Returns the number of Lua return values you are pushing (returning) onto the Lua stack.
Provides it's own error checking.
- Is declared as: __declspec(dllexport) int __cdecl install(lua_State *)
Additional information:
You may (and should) use this define for your install function:
#define PLUGIN_INSTALL_FUNC __declspec(dllexport) int __cdecl
And can now use the definition:
PLUGIN_INSTALL_FUNC install(lua_State *state) { return 0; }
To export as C (if using C++), you can just use
Code: Select all
extern "C" {
/*Your code here */
}
Code: Select all
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}