Added love.event.addListener and removeListener.

addListener takes a function, and names of events that will trigger the function when they're processed inside love.event.poll or love.event.wait. When the given listener function is called, the name of the event as well as all of the event's arguments are passed to the function.

If addListener is called multiple times with the same function and events, it will not add the function more than once.

removeListener takes a function and removes it from all events it was previously added to.
This commit is contained in:
Alex Szpakowski
2015-12-11 20:14:52 -04:00
parent 77b832057d
commit 3eb363059b
5 changed files with 185 additions and 29 deletions
+11 -1
View File
@@ -243,7 +243,17 @@ int luax_register_module(lua_State *L, const WrappedModule &m)
// Register all the functions.
if (m.functions != nullptr)
luax_setfuncs(L, m.functions);
{
const luaL_Reg *l = m.functions;
for (; l->name != nullptr; l++)
{
// Set the module's table as an upvalue for the module's functions.
lua_pushvalue(L, -1);
lua_pushcclosure(L, l->func, 1);
lua_setfield(L, -2, l->name);
}
}
// Register types.
if (m.types != nullptr)