diff --git a/assets/Mods/shared/Types.lua b/assets/Mods/shared/Types.lua index d26b41fac..39cb91a62 100644 --- a/assets/Mods/shared/Types.lua +++ b/assets/Mods/shared/Types.lua @@ -340,6 +340,19 @@ function RegisterKeyBind(Key, Callback) end ---@param Callback fun() function RegisterKeyBind(Key, ModifierKeys, Callback) end +--- Registers a callback for a key-bind, asynchronously +--- Callbacks can only be triggered while the game or debug console is on focus +---@param Key Key +---@param Callback fun() +function RegisterKeyBindAsync(Key, Callback) end + +--- Registers a callback for a key-bind, asynchronously +--- Callbacks can only be triggered while the game or debug console is on focus +---@param Key Key +---@param ModifierKeys ModifierKey[] +---@param Callback fun() +function RegisterKeyBindAsync(Key, Modifiers, Callback) end + ---Checks if, at the time of the invocation, the supplied keys have been registered ---@param Key integer function IsKeyBindRegistered(Key) end @@ -618,6 +631,48 @@ function UE4SS:GetVersion() end ---@return integer, integer, integer function UE4SS.GetVersion() end +--- The 'ModRef' variable is a global variable that's automatically created and is the instance of the current mod. +---@class ModRef +ModRef = {} + +--- Sets a variable that can be accessed by any mod. +---@param VariableName string +---@param Value nil|string|number|boolean|UObject +function ModRef:SetSharedVariable(VariableName, Value) end + +--- Returns a variable that could've been set by another mod. +---@param VariableName string +---@return nil|string|number|boolean|UObject +function ModRef:GetSharedVariable(VariableName) end + +---Returns the type of the shared variable (if it is valid) +---@return string +function ModRef:type() end + +---Exposes some of the CoreUObject API functionality +---@class FPackageName +FPackageName = {} + +---Checks if the string is a ShortPackageName. A ShortPackageName is the leaf name after the last slash in a LongPackageName +---@param PossiblyLongName string +---@return boolean +function FPackageName.IsShortPackageName(PossiblyLongName) end + +---Checks if the string is a ShortPackageName. A ShortPackageName is the leaf name after the last slash in a LongPackageName +---@param PossiblyLongName string +---@return boolean +function FPackageName:IsShortPackageName(PossiblyLongName) end + +---Returns true if the path starts with a valid root (i.e. /Game/, /Engine/, etc) and contains no illegal characters. +---@param PathName string +---@return boolean +function FPackageName.IsValidLongPackageName(PathName) end + +---Returns true if the path starts with a valid root (i.e. /Game/, /Engine/, etc) and contains no illegal characters. +---@param PathName string +---@return boolean +function FPackageName:IsValidLongPackageName(PathName) end + ---Contains helper functions for retrieving which version of Unreal Engine that is being used. ---@class UnrealVersion UnrealVersion = {} @@ -1140,3 +1195,18 @@ function UEnum:RemoveFromNamesAt(Index, Count) end ---@param Count integer ---@param AllowShrinking boolean function UEnum:RemoveFromNamesAt(Index, Count, AllowShrinking) end + +--- Registers a callback that will get called before UEngine::LoadMap is called. +--- The callback params are: UEngine Engine, struct FWorldContext& WorldContext, FURL URL, class UPendingNetGame* PendingGame, string Error +--- Params (except strings & bools & FOutputDevice) must be retrieved via 'Param:Get()' and set via 'Param:Set()'. +---@param Callback fun(Engine: RemoteUnrealParam, World: RemoteUnrealParam, FURL: FURL, PendingGame: RemoteUnrealParam, Error: string) +function RegisterLoadMapPreHook(Callback) end + +--- Registers a callback that will get called after UEngine::LoadMap is called. +--- The callback params are: UEngine Enigne, struct FWorldContext& WorldContext, FURL URL, class UPendingNetGame* PendingGame, string Error +--- Params (except strings & bools & FOutputDevice) must be retrieved via 'Param:Get()' and set via 'Param:Set()'. +---@param Callback fun(Engine: RemoteUnrealParam, World: RemoteUnrealParam, FURL: FURL, PendingGame: RemoteUnrealParam, Error: string) +function RegisterLoadMapPostHook(Callback) end + +--- Creates LogicMods/ directory inside app's Paks/ folder +function CreateLogicModsDirectory() end diff --git a/assets/Mods/shared/UEHelpers/UEHelpers.lua b/assets/Mods/shared/UEHelpers/UEHelpers.lua index 7960d2b8a..2b1936456 100644 --- a/assets/Mods/shared/UEHelpers/UEHelpers.lua +++ b/assets/Mods/shared/UEHelpers/UEHelpers.lua @@ -88,6 +88,8 @@ end ---Returns local player pawn ---@return APawn +---@deprecated +---The behaviour of this function will be changed in future versions to return a correct UPlayer object, please use GetPawn() instead function UEHelpers.GetPlayer() local playerController = UEHelpers.GetPlayerController() if playerController:IsValid() and playerController.Pawn then @@ -96,6 +98,16 @@ function UEHelpers.GetPlayer() return CreateInvalidObject() ---@type APawn end +---Returns a pawn, if any, controlled/owned by first found PlayerController +---@return APawn +function UEHelpers.GetPawn() + local playerController = UEHelpers.GetPlayerController() + if playerController:IsValid() and playerController.Pawn then + return playerController.Pawn + end + return CreateInvalidObject() ---@type APawn +end + local WorldCache = CreateInvalidObject() ---@cast WorldCache UWorld ---Returns the main UWorld ---@return UWorld