1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-28 17:09:41 +00:00

Restore logic that was accidentally removed in !2852. Because of it onUpdate handler in local Lua scripts doesn't work.

This commit is contained in:
Petr Mikheev 2023-04-18 22:19:01 +02:00
parent 35f8cef469
commit 75e47f859c

View file

@ -292,14 +292,19 @@ namespace MWLua
mWorldView.objectAddedToScene(ptr); // assigns generated RefNum if it is not set yet.
mEngineEvents.addToQueue(EngineEvents::OnActive{ getId(ptr) });
if (!ptr.getRefData().getLuaScripts())
LocalScripts* localScripts = ptr.getRefData().getLuaScripts();
if (!localScripts)
{
LuaUtil::ScriptIdsWithInitializationData autoStartConf
= mConfiguration.getLocalConf(getLiveCellRefType(ptr.mRef), ptr.getCellRef().getRefId(), getId(ptr));
// TODO: put to a queue and apply `addAutoStartedScripts` on next `update()`
if (!autoStartConf.empty())
createLocalScripts(ptr, std::move(autoStartConf))->addAutoStartedScripts();
{
localScripts = createLocalScripts(ptr, std::move(autoStartConf));
localScripts->addAutoStartedScripts(); // TODO: put to a queue and apply on next `update()`
}
}
if (localScripts)
mActiveLocalScripts.insert(localScripts);
}
void LuaManager::objectRemovedFromScene(const MWWorld::Ptr& ptr)