Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
36 changes: 36 additions & 0 deletions assets/Mods/shared/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,27 @@ 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.
--- The second parameter `Value` can only be one of the following types: `nil`, `string`, `number`, `bool`, `UObject` (+derivatives), `lightuserdata`.
---@param VariableName string
---@param Value any
function ModRef:SetSharedVariable(VariableName, Value) end

--- Returns a variable that could've been set by another mod.
--- The return value can only be one of the following types: `nil`, `string`, `number`, `bool`, `UObject`(+derivatives), `lightuserdata`.
---@param VariableName string
---@param Value any
---@return any
function ModRef:GetSharedVariable(VariableName, Value) end

---Returns the type of the shared variable (if it is valid)
---@return string
function ModRef:type() end

---Contains helper functions for retrieving which version of Unreal Engine that is being used.
---@class UnrealVersion
UnrealVersion = {}
Expand Down Expand Up @@ -1140,3 +1161,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, FString& 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: RemoteUnrealParam<FURL>, PendingGame: RemoteUnrealParam<UPendingNetGame>, Error: RemoteUnrealParam<FString>)
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, FString& 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: RemoteUnrealParam<FURL>, PendingGame: RemoteUnrealParam<UPendingNetGame>, Error: RemoteUnrealParam<FString>)
function RegisterLoadMapPostHook(Callback) end

--- Creates LogicMods/ directory inside app's Paks/ folder
function CreateLogicModsDirectory() end
11 changes: 11 additions & 0 deletions assets/Mods/shared/UEHelpers/UEHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ end

---Returns local player pawn
---@return APawn
---@deprecated
function UEHelpers.GetPlayer()
local playerController = UEHelpers.GetPlayerController()
if playerController:IsValid() and playerController.Pawn then
Expand All @@ -96,6 +97,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