MCPcopy Create free account
hub / github.com/Tencent/UnLua / DoFile

Method DoFile

Plugins/UnLua/Source/UnLua/Private/UnLuaConsoleCommands.cpp:46–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 void FUnLuaConsoleCommands::DoFile(const TArray<FString>& Args) const
47 {
48 if (Args.Num() != 1)
49 {
50 UE_LOG(LogUnLua, Log, TEXT("usage: lua.dofile <lua.module.path>"));
51 return;
52 }
53
54 auto Env = Module->GetEnv();
55 if (!Env)
56 {
57 UE_LOG(LogUnLua, Warning, TEXT("no available lua env found to run file."));
58 return;
59 }
60
61 const auto& Format = TEXT(R"(
62 local name = "%s"
63 package.loaded[name] = nil
64 collectgarbage("collect")
65 require(name)
66 )");
67 const auto Chunk = FString::Printf(Format, *Args[0]);
68 Env->DoString(Chunk);
69 }
70
71 void FUnLuaConsoleCommands::CollectGarbage(const TArray<FString>& Args) const
72 {

Callers

nothing calls this directly

Calls 3

DoStringMethod · 0.80
NumMethod · 0.45
GetEnvMethod · 0.45

Tested by

no test coverage detected