diff --git a/ScriptExtender/LuaScripts/BuiltinLibraryClient.lua b/ScriptExtender/LuaScripts/BuiltinLibraryClient.lua index 3c934232..24f25fec 100644 --- a/ScriptExtender/LuaScripts/BuiltinLibraryClient.lua +++ b/ScriptExtender/LuaScripts/BuiltinLibraryClient.lua @@ -245,12 +245,27 @@ Ext.Events.SkillGetPropertyDescription:Subscribe(function (e) end) -- Debug helper to get current player character -_C = function () - local statusConsole = Ext.UI.GetByType(117) - if statusConsole == nil then return end - local handle = statusConsole:GetPlayerHandle() - if handle == nil then return end - return Ext.Entity.GetCharacter(handle) +_C = function (playerIndex) + playerIndex = playerIndex or 1 + local playerManager = Ext.Entity.GetPlayerManager() + local player = playerManager.ClientPlayerData[playerIndex] + local charNetID = player and player.CharacterNetId + + return Ext.Entity.GetCharacter(charNetID) +end + +-- Debug helper to get the current player character's weapon +_W = function () + local char = _C() + local item + + if char then + local itemGUID = char:GetItemBySlot("Weapon") + + item = itemGUID and Ext.Entity.GetItem(itemGUID) + end + + return item end -- Debug helper to get character being examined diff --git a/ScriptExtender/LuaScripts/Libs/HelpersGenerator/CustomEntries.lua b/ScriptExtender/LuaScripts/Libs/HelpersGenerator/CustomEntries.lua index f9881ec8..29130466 100644 --- a/ScriptExtender/LuaScripts/Libs/HelpersGenerator/CustomEntries.lua +++ b/ScriptExtender/LuaScripts/Libs/HelpersGenerator/CustomEntries.lua @@ -9,6 +9,33 @@ return { Specific = {SubscribableEventType = SubscribableEventType}, Misc = { [[ +--#region Debug/dev functions + +--- @deprecated For debugging usage only - do not use in mod releases. +--- Returns the active controlled character. +--- @param playerIndex integer? Defaults to 1. +--- @return EclCharacter|EsvCharacter +function _C(playerIndex) end + +--- @deprecated For debugging usage only - do not use in mod releases. +--- Returns the character being examined in the examine UI. +--- Client-only. +--- @return EclCharacter +function _E() end + +--- @deprecated For debugging usage only - do not use in mod releases. +--- Returns the item equipped in the Weapon slot of the active controlled character. +--- In the client context, this uses player 1's character. +--- @return EclItem|EsvItem +function _W() end + +-- Aliases for logging functions. +_D = Ext.Dump +_DS = Ext.DumpShallow +_P = Ext.Utils.Print + +--#endregion + --#region Deprecated Functions (moved to Ext modules) --- @deprecated