Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions assets/Mods/shared/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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<UEngine>, World: RemoteUnrealParam<FWorldContext>, FURL: FURL, PendingGame: RemoteUnrealParam<UPendingNetGame>, 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<UEngine>, World: RemoteUnrealParam<FWorldContext>, FURL: FURL, PendingGame: RemoteUnrealParam<UPendingNetGame>, Error: string)
function RegisterLoadMapPostHook(Callback) end

--- Creates LogicMods/ directory inside app's Paks/ folder
function CreateLogicModsDirectory() end
12 changes: 12 additions & 0 deletions assets/Mods/shared/UEHelpers/UEHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down