double event handlers calls fix
This commit is contained in:
parent
3d4bfeb442
commit
f2c26aed19
@ -135,6 +135,18 @@ function events.on(event, func)
|
|||||||
table.insert(events.handlers[event], func)
|
table.insert(events.handlers[event], func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function events.remove_by_prefix(prefix)
|
||||||
|
for name, handlers in pairs(events.handlers) do
|
||||||
|
if name:sub(1, #prefix) == prefix then
|
||||||
|
events.handlers[name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function pack.unload(prefix)
|
||||||
|
events.remove_by_prefix(prefix)
|
||||||
|
end
|
||||||
|
|
||||||
function events.emit(event, ...)
|
function events.emit(event, ...)
|
||||||
result = nil
|
result = nil
|
||||||
if events.handlers[event] then
|
if events.handlers[event] then
|
||||||
|
|||||||
@ -125,6 +125,15 @@ void scripting::on_world_quit() {
|
|||||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||||
emit_event(pack.id + ".worldquit");
|
emit_event(pack.id + ".worldquit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state->getglobal("pack");
|
||||||
|
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||||
|
state->getfield("unload");
|
||||||
|
state->pushstring(pack.id);
|
||||||
|
state->callNoThrow(1);
|
||||||
|
}
|
||||||
|
state->pop();
|
||||||
|
|
||||||
if (state->getglobal("__scripts_cleanup")) {
|
if (state->getglobal("__scripts_cleanup")) {
|
||||||
state->callNoThrow(0);
|
state->callNoThrow(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user