* Load a class. for example: UClass.Load("/Game/Core/Blueprints/AICharacter.AICharacter_C") */
| 47 | * Load a class. for example: UClass.Load("/Game/Core/Blueprints/AICharacter.AICharacter_C") |
| 48 | */ |
| 49 | int32 UClass_Load(lua_State* L) |
| 50 | { |
| 51 | int32 NumParams = lua_gettop(L); |
| 52 | if (NumParams != 1) |
| 53 | return luaL_error(L, "invalid parameters"); |
| 54 | |
| 55 | const char* ClassPath = lua_tostring(L, 1); |
| 56 | if (!ClassPath) |
| 57 | return luaL_error(L, "invalid class name"); |
| 58 | |
| 59 | FString Name = UTF8_TO_TCHAR(ClassPath); |
| 60 | |
| 61 | #if UNLUA_LEGACY_BLUEPRINT_PATH |
| 62 | LeagcyAppendSuffix(Name); |
| 63 | #endif |
| 64 | |
| 65 | UClass* Class = LoadObject<UClass>(nullptr, *Name); |
| 66 | if (!Class) |
| 67 | return 0; |
| 68 | |
| 69 | if (!UnLua::FLuaEnv::FindEnvChecked(L).GetClassRegistry()->Register(Class)) |
| 70 | return 0; |
| 71 | |
| 72 | UnLua::PushUObject(L, Class); |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Test whether this class is a child of another class |
nothing calls this directly
no test coverage detected