mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 20:53:52 +00:00
Initialize Lua packages in LuaManager::init rather than in constructor.
This commit is contained in:
parent
1e7b9fb6a5
commit
68b8a148d7
2 changed files with 8 additions and 3 deletions
|
@ -31,7 +31,10 @@ namespace MWLua
|
|||
mLocalLoader = createUserdataSerializer(true, mWorldView.getObjectRegistry(), &mContentFileMapping);
|
||||
|
||||
mGlobalScripts.setSerializer(mGlobalSerializer.get());
|
||||
}
|
||||
|
||||
void LuaManager::init()
|
||||
{
|
||||
Context context;
|
||||
context.mIsGlobal = true;
|
||||
context.mLuaManager = this;
|
||||
|
@ -60,14 +63,12 @@ namespace MWLua
|
|||
mCameraPackage = initCameraPackage(localContext);
|
||||
mUserInterfacePackage = initUserInterfacePackage(localContext);
|
||||
mNearbyPackage = initNearbyPackage(localContext);
|
||||
}
|
||||
|
||||
void LuaManager::init()
|
||||
{
|
||||
mKeyPressEvents.clear();
|
||||
for (const std::string& path : mGlobalScriptList)
|
||||
if (mGlobalScripts.addNewScript(path))
|
||||
Log(Debug::Info) << "Global script started: " << path;
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
void LuaManager::update(bool paused, float dt)
|
||||
|
@ -198,6 +199,8 @@ namespace MWLua
|
|||
|
||||
void LuaManager::setupPlayer(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
if (!mInitialized)
|
||||
return;
|
||||
if (!mPlayer.isEmpty())
|
||||
throw std::logic_error("Player is initialized twice");
|
||||
mWorldView.objectAddedToScene(ptr);
|
||||
|
@ -279,6 +282,7 @@ namespace MWLua
|
|||
|
||||
LocalScripts* LuaManager::createLocalScripts(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
assert(mInitialized);
|
||||
std::shared_ptr<LocalScripts> scripts;
|
||||
// When loading a game, it can be called before LuaManager::setPlayer,
|
||||
// so we can't just check ptr == mPlayer here.
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace MWLua
|
|||
private:
|
||||
LocalScripts* createLocalScripts(const MWWorld::Ptr& ptr);
|
||||
|
||||
bool mInitialized = false;
|
||||
LuaUtil::LuaState mLua;
|
||||
sol::table mNearbyPackage;
|
||||
sol::table mUserInterfacePackage;
|
||||
|
|
Loading…
Reference in a new issue