Update StarLua.cpp

This commit is contained in:
Kae 2023-09-05 17:00:04 +10:00
parent c992d4f72a
commit fd915ce672

View File

@ -97,6 +97,9 @@ void LuaContext::setRequireFunction(RequireFunction requireFunction) {
void LuaContext::setCallbacks(String const& tableName, LuaCallbacks const& callbacks) const { void LuaContext::setCallbacks(String const& tableName, LuaCallbacks const& callbacks) const {
auto& eng = engine(); auto& eng = engine();
if (LuaContext::contains(tableName))
return;
auto callbackTable = eng.createTable(); auto callbackTable = eng.createTable();
for (auto const& p : callbacks.callbacks()) for (auto const& p : callbacks.callbacks())
callbackTable.set(p.first, eng.createWrappedFunction(p.second)); callbackTable.set(p.first, eng.createWrappedFunction(p.second));