Skip to content

Commit 8733c22

Browse files
feat(Lua): copying to StructProperty from ScriptStruct userdata
1 parent 918d935 commit 8733c22

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

UE4SS/src/LuaType/LuaUObject.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,18 @@ namespace RC::LuaType
737737
if (params.lua.is_userdata(params.stored_at_index))
738738
{
739739
// StructData as userdata
740-
params.throw_error("push_structproperty::lua_to_memory", "StructData as userdata is not yet implemented but there's userdata on the stack");
740+
auto& lua_scriptstruct = params.lua.get_userdata<UScriptStruct>().get_local_cpp_object();
741+
if (lua_scriptstruct.script_struct == script_struct)
742+
{
743+
struct_property->CopyCompleteValue(params.data, lua_scriptstruct.get_data_ptr());
744+
}
745+
else
746+
{
747+
params.throw_error("push_structproperty::lua_to_memory",
748+
fmt::format("Can't copy struct of type {} into {}",
749+
to_string(lua_scriptstruct.script_struct->GetName()),
750+
to_string(script_struct->GetName())));
751+
}
741752
}
742753
else if (params.lua.is_table(params.stored_at_index))
743754
{

0 commit comments

Comments
 (0)