MCPcopy Create free account
hub / github.com/Norbyte/bg3se / LuaLoadPreinitBootstrap

Method LuaLoadPreinitBootstrap

BG3Extender/Extender/Shared/ExtensionState.cpp:588–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586 }
587
588 void ExtensionStateBase::LuaLoadPreinitBootstrap(ExtensionModConfig const& config, Module const& mod)
589 {
590 auto bootstrapFileName = "BootstrapModule.lua";
591 auto const& sym = GetStaticSymbols();
592
593 auto path = ResolveModScriptPath(mod, bootstrapFileName);
594 if (!sym.FileExists(path)) {
595 return;
596 }
597
598 LuaVirtualPin lua(*this);
599 auto L = lua->GetState();
600 lua::push(L, mod.Info.ModuleUUID);
601 lua_setglobal(L, "ModuleUUID");
602
603 OsiMsg("Loading preinit bootstrap script: " << path);
604 PerfTimer timer;
605 lua->LoadBootstrap(bootstrapFileName, config.ModTable);
606 auto took = timer.time();
607 if (PERF_SHOULD_REPORT(Load, took)) {
608 PERF_REPORT(Load, took, "Loading %s for mod %s took %lld ms", bootstrapFileName, mod.Info.Name.c_str(), took / 1000);
609 }
610
611 lua::push(L, nullptr);
612 lua_setglobal(L, "ModuleUUID");
613 }
614
615 ExtensionStateBase* GetCurrentExtensionState()
616 {

Callers

nothing calls this directly

Calls 5

FileExistsMethod · 0.80
GetStateMethod · 0.80
LoadBootstrapMethod · 0.80
timeMethod · 0.80
pushFunction · 0.50

Tested by

no test coverage detected