diff --git a/lua-api/lib/src/ScriptUtility.cpp b/lua-api/lib/src/ScriptUtility.cpp index 9d9c9ed2..fcdc1440 100644 --- a/lua-api/lib/src/ScriptUtility.cpp +++ b/lua-api/lib/src/ScriptUtility.cpp @@ -376,7 +376,19 @@ sol::object call_function(sol::this_state s, uevr::API::UObject* self, uevr::API throw sol::error("Struct property has no struct"); } - if (struct_desc == get_vector_struct()) { + if (arg_obj.is()) { + const auto arg = arg_obj.as(); + + if (arg.desc != struct_desc) { + if (arg.desc != nullptr) { + throw sol::error(std::format("Invalid argument type for function '{}', expected '{}', got '{}'", ::utility::narrow(fn->get_fname()->to_string()), ::utility::narrow(struct_desc->get_fname()->to_string()), ::utility::narrow(arg.desc->get_fname()->to_string()))); + } else { + throw sol::error(std::format("Invalid argument type for function '{}', expected '{}', got 'nil'", ::utility::narrow(fn->get_fname()->to_string()), ::utility::narrow(struct_desc->get_fname()->to_string()))); + } + } + + memcpy(¶ms[offset], arg.object, struct_desc->get_struct_size()); + } else if (struct_desc == get_vector_struct()) { if (arg_obj.is()) { const auto arg = arg_obj.as(); @@ -396,6 +408,8 @@ sol::object call_function(sol::this_state s, uevr::API::UObject* self, uevr::API } else { throw sol::error("Invalid argument type for FVector"); } + } else { + throw sol::error("Invalid argument type for struct property"); } continue;