| 232 | } |
| 233 | |
| 234 | int Open(lua_State* L) |
| 235 | { |
| 236 | lua_register(L, "print", LogInfo); |
| 237 | luaL_requiref(L, "UnLua", LuaOpen, 1); |
| 238 | luaL_dostring(L, R"( |
| 239 | setmetatable(UnLua, { |
| 240 | __index = function(t, k) |
| 241 | local ok, result = pcall(require, "UnLua." .. tostring(k)) |
| 242 | if ok then |
| 243 | rawset(t, k, result) |
| 244 | return result |
| 245 | else |
| 246 | t.LogWarn(string.format("failed to load module UnLua.%s\n%s", k, result)) |
| 247 | end |
| 248 | end |
| 249 | }) |
| 250 | )"); |
| 251 | |
| 252 | #if UNLUA_WITH_HOT_RELOAD |
| 253 | luaL_dostring(L, R"( |
| 254 | pcall(function() _G.require = require('UnLua.HotReload').require end) |
| 255 | )"); |
| 256 | #endif |
| 257 | |
| 258 | LegacySupport(L); |
| 259 | return 1; |
| 260 | } |
| 261 | |
| 262 | FString GetPackagePath(lua_State* L) |
| 263 | { |
no test coverage detected