-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add global Lua function CreateInvalidObject which returns an in…
…valid UObject (#652) docs: Add CreateInvalidObject function to Types.lua (#652) docs: Fix return value of FindFirstOf, it's just UObject, never nil docs: Add CreateInvalidObject documentation page docs: Modify Changelog.md for current changes
- Loading branch information
Showing
6 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# CreateInvalidObject | ||
|
||
The function `CreateInvalidObject` always returns an object with an `IsValid` function that returns `flase`. | ||
|
||
The sole purpose of the function is to ensure that the mod's Lua code adheres to UE4SS code conventions, where all functions return an invalid `UObject` instead of `nil`. | ||
|
||
## Example | ||
The example code below ensures that you never need to check if `EngineCache` is `nil`, and the same applies to the return value of `GetEngine()`. | ||
```lua | ||
local EngineCache = CreateInvalidObject() ---@cast EngineCache UEngine | ||
---Returns instance of UEngine | ||
---@return UEngine | ||
function GetEngine() | ||
if EngineCache:IsValid() then return EngineCache end | ||
|
||
EngineCache = FindFirstOf("Engine") ---@type UEngine | ||
return EngineCache | ||
end | ||
|
||
``` |