MCPcopy Create free account
hub / github.com/OpenMW/openmw / createLocalScripts

Method createLocalScripts

apps/openmw/mwlua/luamanagerimp.cpp:697–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695 }
696
697 LocalScripts* LuaManager::createLocalScripts(
698 const MWWorld::Ptr& ptr, std::optional<LuaUtil::ScriptIdsWithInitializationData> autoStartConf)
699 {
700 assert(mInitialized);
701 std::shared_ptr<LocalScripts> scripts;
702 const uint32_t type = getLiveCellRefType(ptr.mRef);
703 if (type == ESM::REC_STAT)
704 throw std::runtime_error("Lua scripts on static objects are not allowed");
705 else if (type == ESM::REC_INTERNAL_PLAYER)
706 {
707 scripts = std::make_shared<PlayerScripts>(&mLua, LObject(getId(ptr)));
708 scripts->setAutoStartConf(mConfiguration.getPlayerConf());
709 for (const auto& [name, package] : mPlayerPackages)
710 scripts->addPackage(name, package);
711 }
712 else
713 {
714 scripts = std::make_shared<LocalScripts>(&mLua, LObject(getId(ptr)), &mScriptTracker);
715 if (!autoStartConf.has_value())
716 autoStartConf = mConfiguration.getLocalConf(type, ptr.getCellRef().getRefId(), getId(ptr));
717 scripts->setAutoStartConf(std::move(*autoStartConf));
718 for (const auto& [name, package] : mLocalPackages)
719 scripts->addPackage(name, package);
720 }
721 scripts->setSerializer(mLocalSerializer.get());
722
723 MWWorld::RefData& refData = ptr.getRefData();
724 refData.setLuaScripts(std::move(scripts));
725 return refData.getLuaScripts();
726 }
727
728 void LuaManager::write(ESM::ESMWriter& writer, Loading::Listener& progress)
729 {

Callers

nothing calls this directly

Calls 13

getLiveCellRefTypeFunction · 0.85
LObjectClass · 0.85
getIdFunction · 0.85
setAutoStartConfMethod · 0.80
getPlayerConfMethod · 0.80
addPackageMethod · 0.80
getLocalConfMethod · 0.80
setSerializerMethod · 0.80
setLuaScriptsMethod · 0.80
getLuaScriptsMethod · 0.80
has_valueMethod · 0.45
getRefIdMethod · 0.45

Tested by

no test coverage detected