Skip to content

Commit 74782db

Browse files
committed
fix(Lua): LocalUnrealParam and RemoteUnrealParam no longer tries to handle unregistered indexing
Previously, it wouldn't distinguish between Get/Set, and any random indexing operation, often triggering Lua pushers, which themselves will generate a very confusing error message. This commit removes the Index and NewIndex metamethods from these types, which means Lua will give a standard error when improperly indexing into them without first calling `Get`, for example: `attempt to call a RemoteUnrealParam value (method 'GetFullName')`
1 parent d70f525 commit 74782db

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

UE4SS/include/LuaType/LuaUObject.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,15 +834,6 @@ No overload found for function 'UObject.ProcessConsoleExec'.
834834
private:
835835
auto static setup_metamethods(LuaMadeSimple::Type::BaseObject& base_object) -> void
836836
{
837-
base_object.get_metamethods().create(LuaMadeSimple::Lua::MetaMethod::Index, [](const LuaMadeSimple::Lua& lua) -> int {
838-
prepare_to_handle(Operation::Get, lua);
839-
return 1;
840-
});
841-
842-
base_object.get_metamethods().create(LuaMadeSimple::Lua::MetaMethod::NewIndex, [](const LuaMadeSimple::Lua& lua) -> int {
843-
prepare_to_handle(Operation::Set, lua);
844-
return 0;
845-
});
846837
}
847838

848839
auto static setup_member_functions(LuaMadeSimple::Lua::Table& table) -> void

UE4SS/src/LuaType/LuaUObject.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,15 +2253,6 @@ No overload found for function 'IsA'.
22532253

22542254
auto RemoteUnrealParam::setup_metamethods(BaseObject& base_object) -> void
22552255
{
2256-
base_object.get_metamethods().create(LuaMadeSimple::Lua::MetaMethod::Index, [](const LuaMadeSimple::Lua& lua) -> int {
2257-
prepare_to_handle(Operation::Get, lua);
2258-
return 1;
2259-
});
2260-
2261-
base_object.get_metamethods().create(LuaMadeSimple::Lua::MetaMethod::NewIndex, [](const LuaMadeSimple::Lua& lua) -> int {
2262-
prepare_to_handle(Operation::Set, lua);
2263-
return 0;
2264-
});
22652256
}
22662257

22672258
auto RemoteUnrealParam::setup_member_functions(LuaMadeSimple::Lua::Table& table) -> void

assets/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ Improved performance of script hooks created with `RegisterHook`, and
346346

347347
Types with `get` or `Get` functions now have both variants. ([UE4SS #877](https://github.com/UE4SS-RE/RE-UE4SS/pull/877))
348348

349+
Improved error messages when improperly indexing into `LocalUnrealParam`, and `RemoteUnrealParam` without first calling `Get`. ([UE4SS #1154](https://github.com/UE4SS-RE/RE-UE4SS/pull/1154))
350+
349351
#### UEHelpers [UE4SS #650](https://github.com/UE4SS-RE/RE-UE4SS/pull/650)
350352
- Increased version to 3
351353

0 commit comments

Comments
 (0)