-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UEHelpers improvements. Ensure that all functions return a RemoteObject and not nil. Add more functions, Rework some #650
Conversation
…ith a IsValid function feat: Rework UEHelpers to ensure that all functions never return nil but an object with a IsValid function feat: Rework GetPlayerController(): - PlayerControllers are never just AController, no need to use FindAllOf("Controller") if no APlayerControlle instances exist - If "PlayerControllers" is empty (no APlayerController instanced were found) we should return an object - Remove redundant "pairs(PlayerControllers or {})", we check already if PlayerControllers is nil before - ipairs is slightly faster than pairs and preferable for arrays (tables with numeric keys) - Remove redundant PlayerController IsValid check at the end. PlayerControllers from FindAllOf should all be valid, otherwise the user have to check IsValid on the return anyway feat: Add funtion GetGameEngine(), GetGameViewportClient() and GetWorld() - An instance of UGameEngine, UGameViewportClient and UWorld exists at all time, while PlayerController doesn't exist in main menu of some games feat: Rework GetWorldContextObject() to return UGameViewportClient. (In UE any UObject that has the GetWorld() function is a valid WorldContext)
feat: UEHelpers: Add functions GetKismetStringLibrary and GetKismetTextLibrary docs: UEHelpers: Add annotations for Lua Server
…PlayerControllers array is smaller than 1, in case future UE4SS versions will return only an empty array with FindAllOf
The reason we use |
Regarding |
I think you should add a check for the existence of |
In Lua variables with the same name overshadows the previous declaration. It shouldn't create any compatibility issues if you expose the
Good point, I've no experience with server modding, I'll add a fallback. About Another topic that I would like to discuss. Currently |
feat: Add a fallback to GetWorld(), if PlayerController doesn't exists it will try to get UWorld from UGameViewportClient feat: Use GetWorld() in GetWorldContextObject() instead of GetGameViewportClient() in GetWorldContextObject()
It doesn't really matter about the functions.
This is probably fine, and we can always revert it with a minor patch later if it causes some unforeseen consequences. |
feat: UEHelpers: Add GetPlayer() function feat: UEHelpers: Rework GetPlayerController() to get the player controller from first/main local player
I went back to the roots aka. UE4/5 source code and articles. The APlayerController is the class that is meant to be used by human player to control a pawn. AController is abstraction that can be used for NPC/AI. The only problem that I see if someone used previous GetPlayerController to get any PlayerController with a Pawn on the server. |
The changelog needs to be updated. |
I have also seen games use AController rather than PlayerController for the actual controller, so I do not want to change that. |
…Controller for first PlayerController feat: UEHelpers: Remove fallback to GameViewportClient in GetWorld(), since the new GetPlayerController() should always return a valid controller
If you know and want to support such games, UE4SS must be tested with these customized games. Where do the changes belong in the changelog? Extra section for UEHelpers? Also nobody has commented on version number so far. |
- Revert GetWorldContextObject() back to use PlayerController, since now it should always exists - Add GetPersistentLevel() and GetWorldSettings() functions - Add GetActorFromHitResult(HitResult) function
…d a FName or get a "None" FName
New functions go in the New->Lua API section.
Version 3 is fine. |
…annotated ForceInvalidateCache parameter as optional feat: UEHelpers: Added functions GetGameModeBase() and GetGameStateBase() docs: Added changes from GH-650 to the Changelog
More useful getter functions added. Changelog updated. |
Just tested in another game (LOLLIPOP CHAINSAW RePOP, UE v5.3.1) to have more games covered.
In map screen
In game:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have yet to test this PR.
feat: Remove UEHelpers.FName_None()
…meters to Types.lua docs: Updated the Changelog.md
It slipped my mind that the whole |
…stom Lua Bindings" documentation
Tested in Everspace 2.
In game
I don't know where to find a UE4 or 5 game which uses only AController as base for it's player controller. |
Tested in Satisfactory. Menu
After loading my save file
|
Remnant 2:
In game:
|
…it was replaced by CreateBlankObject()
The PR now requires #666 to be merged first. |
I think this can be merged as soon as #666 has been merged, I think we've done enough testing. |
Just tested with zDEV-UE4SS_v3.0.1-175-g229040b aka. the latest version from 229040b. local invalidObject = CreateInvalidObject()
print("invalidObject variable type: " .. type(invalidObject))
if invalidObject then
print("invalidObject userdata type: " .. invalidObject:type())
print("invalidObject IsValid:" .. tostring(invalidObject:IsValid()))
end Result:
|
Description
UEHelpers changes:
Type of change
How Has This Been Tested?
Output:
In manu:
In game:
Checklist
Additional information
I would like to discuss the changes and get feedback.
I am particularly unsure about the version number.