Skip to content

Commit 40498f7

Browse files
authored
feat(Lua): RegisterCustomProperty now available for ScriptStruct (#1036)
* feat(Lua): RegisterCustomProperty now available for ScriptStruct * chore: Updated changelog
1 parent f6cf84d commit 40498f7

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

UE4SS/src/LuaType/LuaCustomProperty.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ namespace RC::LuaType
4343
owner_or_outer = owner.ToField();
4444
}
4545

46-
Unreal::UStruct* ptr = base->GetClassPrivate();
46+
Unreal::UStruct* ptr{};
47+
if (base->IsA<Unreal::UStruct>())
48+
{
49+
ptr = static_cast<Unreal::UStruct*>(base);
50+
}
51+
else
52+
{
53+
ptr = base->GetClassPrivate();
54+
}
4755
bool class_matches = ptr == owner_or_outer;
4856

4957
if (!class_matches)

UE4SS/src/LuaType/LuaUScriptStruct.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ namespace RC::LuaType
166166
{
167167
// Access the given property in the given UScriptStruct
168168

169-
auto property = static_cast<Unreal::FStructProperty*>(struct_data.script_struct->FindProperty(property_name));
169+
auto property_name_str = property_name.ToString();
170+
auto property = LuaCustomProperty::StaticStorage::property_list.find_or_nullptr(struct_data.script_struct, property_name_str);
171+
if (!property)
172+
{
173+
property = static_cast<Unreal::FStructProperty*>(struct_data.script_struct->FindProperty(property_name));
174+
}
170175
if (!property)
171176
{
172177
lua.throw_error(fmt::format("[handle_unreal_property_value]: Was unable to retrieve property '{}' mapped to '{}'",

assets/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ Added custom module searcher with UTF-8 path support for Lua `require()` ([UE4SS
111111
- Fixed `CreateLogicModsDirectory` to properly create directories with Unicode paths and handle parent directory creation
112112
- Fixed global Lua `print` function to properly handle UTF-8 string conversion
113113

114+
Added support for `UScriptStruct` when using `RegisterCustomProprety` ([UE4SS #1036](https://github.com/UE4SS-RE/RE-UE4SS/pull/1036))
115+
114116
#### Types.lua [PR #650](https://github.com/UE4SS-RE/RE-UE4SS/pull/650)
115117
- Added `NAME_None` definition
116118
- Added `EFindName` enum definition

0 commit comments

Comments
 (0)