* Run a Lua chunk */
| 126 | * Run a Lua chunk |
| 127 | */ |
| 128 | bool RunChunk(lua_State *L, const char *Chunk) |
| 129 | { |
| 130 | if (!Chunk) |
| 131 | { |
| 132 | UE_LOG(LogUnLua, Warning, TEXT("%s: Invalid lua chunk!"), ANSI_TO_TCHAR(__FUNCTION__)); |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | const auto& Env = FLuaEnv::FindEnvChecked(L); |
| 137 | const auto DanglingGuard = Env.GetDanglingCheck()->MakeGuard(); |
| 138 | bool bSuccess = !luaL_dostring(L, Chunk); // loads and runs the given chunk |
| 139 | if (!bSuccess) |
| 140 | { |
| 141 | ReportLuaCallError(L); |
| 142 | return false; |
| 143 | } |
| 144 | |
| 145 | return bSuccess; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Report Lua error |