Skip to content

Commit

Permalink
Lua: Fix UClass object lookup functions not taking a bool as third arg
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 23, 2024
1 parent 3ca54a6 commit ff4c8ff
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua-api/lib/src/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,20 @@ int ScriptContext::setup_bindings() {

return sol::make_object(s, obj); // So it goes through sol_lua_push for our pooling mechanism
},
"get_objects_matching", [](sol::this_state s, uevr::API::UClass& self, sol::function fn) -> sol::object {
"get_objects_matching", [](sol::this_state s, uevr::API::UClass& self, sol::object allow_default_obj) -> sol::object {
const bool allow_default = allow_default_obj.is<bool>() ? allow_default_obj.as<bool>() : false;
auto tbl = sol::state_view{s}.create_table();
auto objects = self.get_objects_matching<uevr::API::UObject>();
auto objects = self.get_objects_matching<uevr::API::UObject>(allow_default);

for (auto obj : objects) {
tbl.add(sol::make_object(s, obj));
}

return sol::make_object(s, tbl);
},
"get_first_object_matching", [](sol::this_state s, uevr::API::UClass& self) -> sol::object {
auto object = self.get_first_object_matching<uevr::API::UObject>();
"get_first_object_matching", [](sol::this_state s, uevr::API::UClass& self, sol::object allow_default_obj) -> sol::object {
const bool allow_default = allow_default_obj.is<bool>() ? allow_default_obj.as<bool>() : false;
auto object = self.get_first_object_matching<uevr::API::UObject>(allow_default);

if (object == nullptr) {
return sol::make_object(s, sol::nil);
Expand Down

0 comments on commit ff4c8ff

Please sign in to comment.