From 8cb9e68683ea36593d1475affbb16bafa906e3b3 Mon Sep 17 00:00:00 2001 From: praydog Date: Sat, 26 Oct 2024 17:59:46 -0700 Subject: [PATCH] Lua: Add UStruct:find_property, UEVR_FProperty --- lua-api/lib/src/ScriptContext.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lua-api/lib/src/ScriptContext.cpp b/lua-api/lib/src/ScriptContext.cpp index 7a811a53..68d4d4e1 100644 --- a/lua-api/lib/src/ScriptContext.cpp +++ b/lua-api/lib/src/ScriptContext.cpp @@ -655,6 +655,15 @@ int ScriptContext::setup_bindings() { return sol::make_object(s, f); }, + "find_property", [](sol::this_state s, uevr::API::UStruct& self, const std::wstring& name) { + auto p = self.find_property(name); + + if (p == nullptr) { + return sol::make_object(s, sol::lua_nil); + } + + return sol::make_object(s, p); + }, "get_child_properties", &uevr::API::UStruct::get_child_properties, "get_properties_size", &uevr::API::UStruct::get_properties_size, "get_children", &uevr::API::UStruct::get_children @@ -766,6 +775,17 @@ int ScriptContext::setup_bindings() { "get_class", &uevr::API::FField::get_class ); + m_lua.new_usertype("UEVR_FProperty", + sol::base_classes, sol::bases(), + "get_offset", &uevr::API::FProperty::get_offset, + "get_property_flags", &uevr::API::FProperty::get_property_flags, + "is_param", &uevr::API::FProperty::is_param, + "is_out_param", &uevr::API::FProperty::is_out_param, + "is_return_param", &uevr::API::FProperty::is_return_param, + "is_reference_param", &uevr::API::FProperty::is_reference_param, + "is_pod", &uevr::API::FProperty::is_pod + ); + m_lua.new_usertype("UEVR_FFieldClass", "get_fname", &uevr::API::FFieldClass::get_fname, "get_name", &uevr::API::FFieldClass::get_name