From f8929bdf1807e127f38c5d55fdf9347f680fd10c Mon Sep 17 00:00:00 2001 From: Rubat <3299036+robotboy655@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:48:09 +0300 Subject: [PATCH] Finger poser updates correctly on entity loss --- .../weapons/gmod_tool/stools/finger.lua | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua b/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua index 5f9afa356d..c7039ebad7 100644 --- a/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua +++ b/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua @@ -528,6 +528,7 @@ end local OldHand = nil local OldEntity = nil +local OldEntityValid = false --[[ Updates the selected entity with the values from the convars @@ -541,12 +542,13 @@ function TOOL:Think() if ( self.NextUpdate && self.NextUpdate > CurTime() ) then return end - if ( CLIENT && ( OldHand != hand || OldEntity != selected ) ) then + if ( CLIENT && ( OldHand != hand || OldEntity != selected || IsValid( selected ) != OldEntityValid ) ) then OldHand = hand OldEntity = selected + OldEntityValid = IsValid( selected ) - self:RebuildControlPanel( hand ) + self:RebuildControlPanel( self:HandEntity(), self:HandNum() ) end @@ -565,18 +567,6 @@ for i = 0, VarsOnHand do TOOL.ClientConVar[ "" .. i ] = "0 0" end --- Rebuilds the context menu based on the current selected entity/hand -function TOOL:RebuildControlPanel( hand ) - - -- We've selected a new entity - rebuild the controls list - local CPanel = controlpanel.Get( "finger" ) - if ( !CPanel ) then return end - - CPanel:ClearControls() - self.BuildCPanel( CPanel, self:HandEntity(), self:HandNum() ) - -end - local ConVarsDefault = TOOL:BuildConVarList() function TOOL.BuildCPanel( CPanel, ent, hand )