Event queue

This commit is contained in:
InfiniteCoder
2024-03-07 22:33:08 +03:00
parent f8e02e1b3b
commit fcb420c4c7
7 changed files with 131 additions and 80 deletions
+6 -6
View File
@@ -22,20 +22,20 @@ void scripting::on_frontend_init(Hud* hud) {
scripting::state->openlib("hud", hudlib, 0);
for (auto& pack : scripting::engine->getContentPacks()) {
if (state->getglobal(pack.id+".hudopen")) {
emit_event(pack.id + ".hudopen", [&] (lua::LuaState* state) {
state->pushinteger(hud->getPlayer()->getId());
state->callNoThrow(1);
}
return 1;
});
}
}
void scripting::on_frontend_close() {
scripting::hud = nullptr;
for (auto& pack : scripting::engine->getContentPacks()) {
if (state->getglobal(pack.id+".hudclose")) {
emit_event(pack.id + ".hudclose", [&] (lua::LuaState* state) {
state->pushinteger(hud->getPlayer()->getId());
state->callNoThrow(1);
}
return 1;
});
}
}