Step-by-step workflow for creating a new mini-mbm Lua plugin (shared library). Use when: adding a new plugin, creating a new box2d-style Lua binding, adding a new plugin-helper-backed feature, wiring a new plugin into the CMake build, implementing luaopen_ entry points, implementing the PLUGIN callback interface, creating a tilemap-style or ImGui-style plugin.
Invoke this skill whenever the task is to create a new plugin for the mini-mbm engine — a shared library (.so / .dll) or iOS static archive that exposes a Lua API via require "myplugin".
Every mini-mbm plugin must fulfil all three of these contracts:
// myplugin-lua.h
extern "C" MY_PLUGIN_API int luaopen_myplugin (lua_State *lua);
extern "C" MY_PLUGIN_API int luaopen_libmyplugin(lua_State *lua);
luaopen_<name> for require "myplugin" and for .luaopen_lib<name>require "libmyplugin"luaopen_libmyplugin must always delegate to luaopen_myplugin — never duplicate the body.luaL_newlib and returns the table. For PLUGIN-type plugins it calls plugin_doSubscribe (see §1d) and returns the plugin table.// myplugin-lua.h
#ifndef MYPLUGIN_IMPORTER_H
#define MYPLUGIN_IMPORTER_H
#if defined (__GNUC__)
#define MY_PLUGIN_API __attribute__ ((__visibility__("default")))
#elif defined (WIN32)
#ifdef MY_PLUGIN_BUILD_DLL
#define MY_PLUGIN_API __declspec(dllexport)
#else
#define MY_PLUGIN_API __declspec(dllimport)
#endif
#endif
extern "C" {
#include <lualib.h>
#include <lauxlib.h>
#include <lua.h>
}
extern "C" MY_PLUGIN_API int luaopen_myplugin (lua_State *lua);
extern "C" MY_PLUGIN_API int luaopen_libmyplugin(lua_State *lua);
#endif // !MYPLUGIN_IMPORTER_H
__attribute__ ((__visibility__("default")))__declspec(dllexport) when MY_PLUGIN_BUILD_DLL is defined, __declspec(dllimport) otherwise. Add #pragma comment(lib, "lua5.4.lib") if needed (see ImGui plugin).If the plugin needs per-frame onLoop(), input events, or render hooks, inherit from PLUGIN:
// include/core_mbm/plugin-callback.h (already in the repo — do NOT copy)
class PLUGIN {