Better error handling in 'Call a Lua Function' k2node

This commit is contained in:
2025-04-07 18:00:45 -04:00
parent d35125eb70
commit 865297331a
6 changed files with 90 additions and 29 deletions

View File

@@ -223,12 +223,26 @@ void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place)
}
void UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place)
bool UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place)
{
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context);
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
if (NotInitialized(sb)) return;
if (NotInitialized(sb)) return false;
mode->LuaCallEnd(InvocationKind::LUA_PROBE, place);
FlxStreamBuffer &result = mode->LuaCallGetResult();
SimpleDynamicTag tag = result.read_simple_dynamic_tag();
if (tag != SimpleDynamicTag::STRING)
{
UE_LOG(LogLuprexIntegration, Error, TEXT("corruption in lua_probe"));
return false;
}
FString ErrorMessage = result.read_fstring();
if (!ErrorMessage.IsEmpty())
{
UE_LOG(LogLuprex, Error, TEXT("%s"), *ErrorMessage);
return false;
}
return true;
}
UlxLuaValues *UlxLuaCallLibrary::LuaCallGetRest(UObject *context)