Plugin writing specifications

MicroMacro plugins and plugins only. You can request or share your plugin (either compiled or source code) here.
Post Reply
Message
Author
User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Plugin writing specifications

#1 Post by Administrator » Mon Mar 10, 2008 3:05 am

Edit: These specifications do not apply to MicroMacro 1.0 beta 7+. You can use native Lua modules instead.

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++.
    Every Lua function you will be registering will follow these properties:
    • 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.
    Use of the callback function DllMain is optional.

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 */
}
Lua includes (lua.h, luaxlib.h, lualib.h) should all be inside a extern "C" block if using C++.

Code: Select all

extern "C"
{
  #include <lua.h>
  #include <lauxlib.h>
  #include <lualib.h>
}

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests