Skip to content

Commit

Permalink
library: set minimaprender2d metatable
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamcake committed Nov 30, 2024
1 parent 5819a8a commit 0ac8aad
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/library/plugin/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,11 @@ uint8_t _bolt_plugin_add(const char* path, struct Plugin* plugin) {
#define SETMETA(NAME) \
lua_pushliteral(plugin->state, #NAME "meta"); \
_bolt_api_push_metatable_##NAME(plugin->state); \
lua_settable(plugin->state, LUA_REGISTRYINDEX);
#define DUPEMETA(NAME, NEWNAME) \
lua_pushliteral(plugin->state, #NEWNAME "meta"); \
lua_pushliteral(plugin->state, #NAME "meta"); \
lua_gettable(plugin->state, LUA_REGISTRYINDEX); \
lua_settable(plugin->state, LUA_REGISTRYINDEX);
SETMETA(render2d)
SETMETA(render3d)
Expand All @@ -1236,11 +1241,10 @@ lua_settable(plugin->state, LUA_REGISTRYINDEX);
SETMETA(mousebutton)
SETMETA(scroll)
SETMETA(mouseleave)
lua_pushliteral(plugin->state, "mousebuttonupmeta");
lua_pushliteral(plugin->state, "mousebuttonmeta");
lua_gettable(plugin->state, LUA_REGISTRYINDEX);
lua_settable(plugin->state, LUA_REGISTRYINDEX);
#undef PUSHMETA
DUPEMETA(mousebutton, mousebuttonup)
DUPEMETA(render2d, minimaprender2d)
#undef SETMETA
#undef DUPEMETA

// attempt to run the function
if (lua_pcall(plugin->state, 0, 0, 0)) {
Expand Down

0 comments on commit 0ac8aad

Please sign in to comment.