From 38584863cb440d1e444bf59600b182872313c60f Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:00:45 +0300 Subject: [PATCH 01/12] Major optimizations --- lua/entities/gmod_wire_target_finder.lua | 469 +++++++++++++---------- 1 file changed, 275 insertions(+), 194 deletions(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 8bf9b61b3d..81839f4839 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -17,8 +17,11 @@ end local MaxBogeys = GetConVar("wire_target_finders_maxbogeys") local MaxTargets = GetConVar("wire_target_finders_maxtargets") -function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrusters, props, propmodel, vehicles, playername, casesen, rpgs, painttarget, minrange, maxtargets, maxbogeys, notargetowner, entity, notownersstuff, steamidfilter, colorcheck, colortarget, pcolR, pcolG, pcolB, pcolA, checkbuddylist, onbuddylist ) - local ttable = { -- For dupe support +function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrusters, props, propmodel, vehicles, playername, casesen, rpgs, painttarget, minrange, maxtargets, maxbogeys, notargetowner, entity, notownersstuff, steamidfilter, colorcheck, colortarget, pcolR, pcolG, pcolB, pcolA, checkbuddylist, onbuddylist) + -- For dupe support + local tab = self:GetTable() + + table.Merge( tab, { range = maxrange, players = players, npcs = npcs, @@ -48,112 +51,120 @@ function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrust checkbuddylist = checkbuddylist, onbuddylist = onbuddylist, entity = entity, - } - table.Merge( self:GetTable(), ttable ) - - self.MaxRange = maxrange - self.MinRange = minrange or 1 - self.TargetPlayer = players - self.NoTargetOwner = notargetowner - self.NoTargetOwnersStuff = notownersstuff - self.TargetNPC = npcs - self.NPCName = npcname - self.TargetBeacon = beacons - self.TargetHoverballs = hoverballs - self.TargetThrusters = thrusters - self.TargetProps = props - self.PropModel = propmodel - self.TargetVehicles = vehicles - self.PlayerName = playername - self.SteamName = steamidfilter - self.ColorCheck = colorcheck - self.ColorTarget = colortarget - self.PcolR = pcolR - self.PcolG = pcolG - self.PcolB = pcolB - self.PcolA = pcolA - self.CaseSen = casesen - self.TargetRPGs = rpgs - self.EntFil = entity - self.CheckBuddyList = checkbuddylist - self.OnBuddyList = onbuddylist - self.PaintTarget = painttarget - self.MaxTargets = math.floor(math.Clamp(maxtargets or 1, 1, MaxTargets:GetInt())) - self.MaxBogeys = math.floor(math.Clamp(maxbogeys or 1, self.MaxTargets, MaxBogeys:GetInt())) - - if (self.SelectedTargets) then --unpaint before clearing - for _,ent in pairs(self.SelectedTargets) do - self:TargetPainter(ent, false) + } ) + + tab.MaxRange = maxrange + tab.MinRange = minrange or 1 + tab.TargetPlayer = players + tab.NoTargetOwner = notargetowner + tab.NoTargetOwnersStuff = notownersstuff + tab.TargetNPC = npcs + tab.NPCName = npcname + tab.TargetBeacon = beacons + tab.TargetHoverballs = hoverballs + tab.TargetThrusters = thrusters + tab.TargetProps = props + tab.PropModel = propmodel + tab.TargetVehicles = vehicles + tab.PlayerName = playername + tab.SteamName = steamidfilter + tab.ColorCheck = colorcheck + tab.ColorTarget = colortarget + tab.PcolR = pcolR + tab.PcolG = pcolG + tab.PcolB = pcolB + tab.PcolA = pcolA + tab.CaseSen = casesen + tab.TargetRPGs = rpgs + tab.EntFil = entity + tab.CheckBuddyList = checkbuddylist + tab.OnBuddyList = onbuddylist + tab.PaintTarget = painttarget + tab.MaxTargets = math.floor(math.Clamp(maxtargets or 1, 1, MaxTargets:GetInt())) + tab.MaxBogeys = math.floor(math.Clamp(maxbogeys or 1, tab.MaxTargets, MaxBogeys:GetInt())) + + if (tab.SelectedTargets) then -- Unpaint before clearing + for _, ent in pairs(tab.SelectedTargets) do + tab.TargetPainter(self, ent, false, tab) end end - self.SelectedTargets = {} - self.SelectedTargetsSel = {} + + tab.SelectedTargets = {} + tab.SelectedTargetsSel = {} local AdjOutputs = {} local AdjOutputsT = {} - for i = 1, self.MaxTargets do - table.insert(AdjOutputs, tostring(i)) + + for i = 1, tab.MaxTargets do + local i_string = tostring(i) + table.insert(AdjOutputs, i_string) table.insert(AdjOutputsT, "NORMAL") - table.insert(AdjOutputs, tostring(i) .. "_Ent") + table.insert(AdjOutputs, i_string .. "_Ent") table.insert(AdjOutputsT, "ENTITY") end + WireLib.AdjustSpecialOutputs(self, AdjOutputs, AdjOutputsT) + tab.Selector = {} + tab.Selector.Next = {} + tab.Selector.Prev = {} + tab.Selector.Hold = {} - self.Selector = {} - self.Selector.Next = {} - self.Selector.Prev = {} - self.Selector.Hold = {} local AdjInputs = {} + for i = 1, self.MaxTargets do - local inputnext = tostring(i) .. "-NextTarget" - --local inputprev = tostring(i).."-PrevTarget" - local inputhold = tostring(i) .. "-HoldTarget" - self.Selector.Next[inputnext] = i - --self.Selector.Prev[inputprev] = i - --self.Selector.Hold[inputhold] = i + local i_string = tostring(i) + local inputnext = i_string .. "-NextTarget" + local inputhold = i_string .. "-HoldTarget" + tab.Selector.Next[inputnext] = i + table.insert(AdjInputs, inputnext) - --table.insert(AdjInputs, inputprev) table.insert(AdjInputs, inputhold) end + table.insert(AdjInputs, "Hold") table.insert(AdjInputs, "Ignore [ARRAY]") Wire_AdjustInputs(self, AdjInputs) - - self:ShowOutput(false) end -function ENT:TriggerInput(iname, value) - if iname == "Ignore" then - self.Ignored = value - return - end +function ENT:TriggerInput(name, value) + if name == "Ignore" then + local ignored_hash = {} + self.Ignored = ignored_hash - if value > 0 and self.Selector.Next[iname] then - self:SelectorNext(self.Selector.Next[iname]) - --[[elseif self.Selector.Prev[iname] then - self:SelectorPrev(self.Selector.Prev[iname]) - elseif self.Selector.Hold[iname] then - self:SelectorHold(self.Selector.Hold[iname]) - ]] + for _, ent in ipairs(value) do + ignored_hash[ent] = true + end + + else + local select_next = self.Selector.Next + + if value > 0 and select_next[name] then + self:SelectorNext(select_next) + end end end - function ENT:GetBeaconPos(sensor) local ch = 1 - if sensor.Inputs and sensor.Inputs.Target.SrcId then - ch = tonumber(sensor.Inputs.Target.SrcId) + local inputs = sensor.Inputs + + if inputs and inputs.Target.SrcId then + ch = tonumber(inputs.Target.SrcId) end - if self.SelectedTargets[ch] then - if not self.SelectedTargets[ch]:IsValid() then - self.SelectedTargets[ch] = nil + + local selected_targets = self.SelectedTargets + local selected = selected_targets[ch] + + if selected then + if not selected:IsValid() then + selected_targets[ch] = nil Wire_TriggerOutput(self, tostring(ch), 0) return sensor:GetPos() end - return self.SelectedTargets[ch]:GetPos() + return selected:GetPos() end return sensor:GetPos() @@ -161,75 +172,98 @@ end function ENT:GetBeaconVelocity(sensor) local ch = 1 - if sensor.Inputs and sensor.Inputs.Target.SrcId then - ch = tonumber(sensor.Inputs.Target.SrcId) + local inputs = sensor.Inputs + + if inputs and inputs.Target.SrcId then + ch = tonumber(inputs.Target.SrcId) end - local selected = self.SelectedTargets[ch] + + local selected_targets = self.SelectedTargets + local selected = selected_targets[ch] + if selected then if not selected:IsValid() then - self.SelectedTargets[ch] = nil + selected_targets[ch] = nil Wire_TriggerOutput(self, tostring(ch), 0) return sensor:GetVelocity() end + return selected:GetVelocity() end + return sensor:GetVelocity() end function ENT:SelectorNext(ch) - if self.Bogeys and #self.Bogeys > 0 then - if not self.SelectedTargetsSel[ch] then self.SelectedTargetsSel[ch] = 1 end + local tab = self:GetTable() + local bogeys = tab.Bogeys - local sel = self.SelectedTargetsSel[ch] - if (sel > #self.Bogeys) then sel = 1 end + if bogeys and #bogeys > 0 then + local selected_targets_sel = tab.SelectedTargetsSel + if not selected_targets_sel[ch] then selected_targets_sel[ch] = 1 end - local target = self.SelectedTargets[ch] - if target and target:IsValid() then + local sel = selected_targets_sel[ch] + if (sel > bogeys) then sel = 1 end + + local paint_target = tab.PaintTarget + local selected_targets = tab.SelectedTargets + local target = selected_targets[ch] - if (self.PaintTarget) then self:TargetPainter(target, false) end - table.insert(self.Bogeys, target) --put old target back + if target and target:IsValid() then + if paint_target then tab.TargetPainter(self, target, false, tab) end + table.insert(bogeys, target) -- Put old target back - target = table.remove(self.Bogeys, sel) --pull next target - self.SelectedTargets[ch] = target + target = table.remove(bogeys, sel) -- Pull next target + selected_targets[ch] = target - if (self.PaintTarget) then self:TargetPainter(self.SelectedTargets[ch], true) end + if paint_target then tab.TargetPainter(self, selected_targets[ch], true, tab) end else - self.SelectedTargets[ch] = table.remove(self.Bogeys, sel) --pull next target - if (self.PaintTarget) then self:TargetPainter(self.SelectedTargets[ch], true) end + selected_targets[ch] = table.remove(bogeys, sel) -- Pull next target + if paint_target then tab.TargetPainter(self, selected_targets[ch], true, tab) end end - self.SelectedTargetsSel[ch] = sel + 1 - self.Inputs[ch .. "-HoldTarget"].Value = 1 --put the channel on hold so it wont change in the next scan - Wire_TriggerOutput(self, tostring(ch), 1) - Wire_TriggerOutput(self, tostring(ch) .. "_Ent", self.SelectedTargets[ch]) + selected_targets_sel[ch] = sel + 1 + + -- Put the channel on hold so it wont change in the next scan + tab.Inputs[ch .. "-HoldTarget"].Value = 1 + + local ch_string = tostring(ch) + Wire_TriggerOutput(self, ch_string, 1) + Wire_TriggerOutput(self, ch_string .. "_Ent", selected_targets[ch]) end end --function ENT:SelectorPrev(ch) end --TODO if needed -function ENT:FindColor(contact) - if (not self.ColorCheck) then return true end - local col = contact:GetColor() - if (col.r == self.PcolR) and (col.g == self.PcolG) and (col.b == self.PcolB) and (col.a == self.PcolA) then - return self.ColorTarget +function ENT:FindColor(contact, tab) + if not tab.ColorCheck then return true end + local color = contact:GetColor() + + if color.r == tab.PcolR and color.g == tab.PcolG and color.b == tab.PcolB and color.a == tab.PcolA then + return tab.ColorTarget else - return not self.ColorTarget + return not tab.ColorTarget end end -function ENT:CheckTheBuddyList(friend) - if not self.CheckBuddyList or not CPPI then return true end - local ply = self:GetPlayer() +function ENT:CheckTheBuddyList(ply, tab) + if not CPPI or not tab.CheckBuddyList return true end + + local ply = tab.GetPlayer(self) if not ply:IsValid() then return false end local friends = ply:CPPIGetFriends() + if istable(friends) then - for _, v in pairs(friends) do - if v == friend then return self.OnBuddyList end + for _, friend in pairs(friends) do + if friend == ply then + return tab.OnBuddyList + end end end - return not self.OnBuddyList + + return not tab.OnBuddyList end -- Like the old FindInValue but without string.find() and for multiple values split by either a space or a comma. @@ -248,141 +282,188 @@ local function isOneOf(value, values_str, case_sensitive) return false end -local function CheckPlayers(self, contact) - if self.NoTargetOwner and self:GetPlayer() == contact then return false end - if not isOneOf(contact:GetName(), self.PlayerName, self.CaseSen) then return false end +local function CheckPlayers(self, contact, tab) + if tab.NoTargetOwner and tab.GetPlayer(self) == contact then return false end + if not isOneOf(contact:GetName(), tab.PlayerName, tab.CaseSen) then return false end -- Check if the player's steamid/steamid64 matches the SteamIDs - if self.SteamName:Trim() ~= "" then - local contact_steamid, contact_steamid64 = contact:SteamID(), contact:SteamID64() or "multirun" - if not ( isOneOf(contact_steamid, self.SteamName, self.CaseSen) or isOneOf(contact_steamid64, self.SteamName, self.CaseSen) ) then + if tab.SteamName:Trim() ~= "" then + local contact_steamid, contact_steamid64 = contact:SteamID(), contact:SteamID64() + + if not isOneOf(contact_steamid, tab.SteamName, tab.CaseSen) or isOneOf(contact_steamid64, tab.SteamName, tab.CaseSen) then return false end end - return self:FindColor(contact) and self:CheckTheBuddyList(contact) + return tab.FindColor(self, contact, tab) and tab.CheckTheBuddyList(self, contact, tab) end function ENT:Think() BaseClass.Think(self) - if not (self.Inputs.Hold and self.Inputs.Hold.Value > 0) then + local tab = self:GetTable() + + if not (tab.Inputs.Hold and tab.Inputs.Hold.Value > 0) then -- Find targets that meet requirements - local mypos = self:GetPos() local bogeys, dists, ndists = {}, {}, 0 - for _, contact in ipairs(ents.FindInSphere(mypos, self.MaxRange or 10)) do + + local pos = self:GetPos() + local max_range = tab.MaxRange + local min_range = tab.MinRange + local ignored = tab.Ignored + local no_target_owner = tab.NoTargetOwnersStuff + local target_npc = tab.TargetNPC + local target_player = tab.TargetPlayer + local target_beacon = tab.TargetBeacon + local target_rpgs = tab.TargetRPGs + local target_hoverballs = tab.TargetHoverballs + local target_thrusters = tab.TargetThrusters + local target_props = tab.TargetProps + local target_vehicles = tab.TargetVehicles + local ent_filter = tab.EntFil + local prop_model = tab.PropModel + local npc_name = tab.NPCName + + for _, contact in ipairs(ents.FindInSphere(pos, max_range)) do local class = contact:GetClass() if -- Ignore array of entities if provided - (not self.Ignored or not table.HasValue(self.Ignored, contact) ) and + (not ignored or not ignored[contact]) and -- Ignore owned stuff if checked - ((not self.NoTargetOwnersStuff or (class == "player") or (WireLib.GetOwner(contact) ~= self:GetPlayer())) and + ((not no_target_owner or (class == "player") or (WireLib.GetOwner(contact) ~= tab.GetPlayer(self))) and -- NPCs - ((self.TargetNPC and (contact:IsNPC()) and (isOneOf(class, self.NPCName))) or + ((target_npc and (contact:IsNPC()) and (isOneOf(class, npc_name))) or --Players - (self.TargetPlayer and (class == "player") and CheckPlayers(self, contact) or + (target_player and (class == "player") and CheckPlayers(self, contact, tab) or --Locators - (self.TargetBeacon and (class == "gmod_wire_locator")) or + (target_beacon and (class == "gmod_wire_locator")) or --RPGs - (self.TargetRPGs and (class == "rpg_missile")) or + (target_rpgs and (class == "rpg_missile")) or -- Hoverballs - (self.TargetHoverballs and (class == "gmod_hoverball" or class == "gmod_wire_hoverball")) or + (target_hoverballs and (class == "gmod_hoverball" or class == "gmod_wire_hoverball")) or -- Thruster - (self.TargetThrusters and (class == "gmod_thruster" or class == "gmod_wire_thruster" or class == "gmod_wire_vectorthruster")) or + (target_thrusters and (class == "gmod_thruster" or class == "gmod_wire_thruster" or class == "gmod_wire_vectorthruster")) or -- Props - (self.TargetProps and (class == "prop_physics") and (isOneOf(contact:GetModel(), self.PropModel))) or + (target_props and (class == "prop_physics") and (isOneOf(contact:GetModel(), prop_model))) or -- Vehicles - (self.TargetVehicles and contact:IsVehicle()) or + (target_vehicles and contact:IsVehicle()) or -- Entity classnames - (self.EntFil ~= "" and isOneOf(class, self.EntFil))))) + (ent_filter ~= "" and isOneOf(class, ent_filter))))) then - local dist = (contact:GetPos() - mypos):Length() - if (dist >= self.MinRange) then + if (contact:GetPos():Distance(pos) >= min_range) then -- put targets in a table index by the distance from the finder - bogeys[dist] = contact - ndists = ndists + 1 + bogeys[dist] = contact dists[ndists] = dist end end end -- sort the list of bogeys by key (distance) - self.Bogeys = {} - self.InRange = {} + tab.Bogeys = {} + tab.InRange = {} table.sort(dists) + local k = 1 + local bogeys = tab.Bogeys + local max_bogeys = tab.MaxBogeys + for i, d in ipairs(dists) do - if not self:IsTargeted(bogeys[d], i) then - self.Bogeys[k] = bogeys[d] + if not tab.IsTargeted(self, bogeys[d], i, tab) then + bogeys[k] = bogeys[d] k = k + 1 - if k > self.MaxBogeys then break end + + if k > max_bogeys then + break + end end end - -- check that the selected targets are valid - for i = 1, self.MaxTargets do - if (self:IsOnHold(i)) then - self.InRange[i] = true + local max_targets = tab.MaxTargets + local paint_target = tab.PaintTarget + local selected_targets = tab.SelectedTargets + local in_range = tab.InRange + + for i = 1, max_targets do + if tab.IsOnHold(self, i, tab) then + in_range[i] = true end - if not self.InRange[i] or not self.SelectedTargets[i] or self.SelectedTargets[i] == nil or not self.SelectedTargets[i]:IsValid() then - if (self.PaintTarget) then self:TargetPainter(self.SelectedTargets[i], false) end - if (#self.Bogeys > 0) then - self.SelectedTargets[i] = table.remove(self.Bogeys, 1) - if (self.PaintTarget) then self:TargetPainter(self.SelectedTargets[i], true) end - Wire_TriggerOutput(self, tostring(i), 1) - Wire_TriggerOutput(self, tostring(i) .. "_Ent", self.SelectedTargets[i]) + if not in_range[i] or not selected_targets[i] or selected_targets[i] == nil or not selected_targets[i]:IsValid() then + local i_string = tostring(i) + + if paint_target then + tab.TargetPainter(self, selected_targets[i], false, tab) + end + + if (#bogeys > 0) then + selected_targets[i] = table.remove(bogeys, 1) + + if paint_target then + tab.TargetPainter(self, selected_targets[i], true, tab) + end + + Wire_TriggerOutput(self, i_string, 1) + Wire_TriggerOutput(self, i_string .. "_Ent", selected_targets[i]) else - self.SelectedTargets[i] = nil - Wire_TriggerOutput(self, tostring(i), 0) - Wire_TriggerOutput(self, tostring(i) .. "_Ent", NULL) + selected_targets[i] = nil + Wire_TriggerOutput(self, i_string, 0) + Wire_TriggerOutput(self, i_string .. "_Ent", NULL) end end end - end - -- temp hack - if self.SelectedTargets[1] then - self:ShowOutput(true) - else - self:ShowOutput(false) - end self:NextThink(CurTime() + 1) + return true end -function ENT:IsTargeted(bogey, bogeynum) - for i = 1, self.MaxTargets do - local target = self.SelectedTargets[i] +function ENT:IsTargeted(bogey, bogeynum, tab) + local max_range = tab.MaxTargets + local paint_target = tab.PaintTarget + local selected_targets = tab.SelectedTargets + local in_range = tab.InRange + local inputs = tab.Inputs + + for i = 1, max_range do + local target = selected_targets[i] + if target and (target == bogey) then -- hold this target - if self.Inputs[i .. "-HoldTarget"] and self.Inputs[i .. "-HoldTarget"].Value > 0 then - self.InRange[i] = true + local i_string = i .. "-HoldTarget" + + if inputs[i_string] and inputs[i_string].Value > 0 then + in_range[i] = true return true end -- this bogey is not as close as others, untarget it and let it be add back to the list - if bogeynum > self.MaxTargets then - self.SelectedTargets[i] = nil - if self.PaintTarget then self:TargetPainter(bogey, false) end + if bogeynum > max_range then + selected_targets[i] = nil + + if paint_target then + tab.TargetPainter(self, bogey, false, tab) + end + return false end - self.InRange[i] = true + in_range[i] = true + return true end end + return false end -function ENT:IsOnHold(ch) - if self.Inputs[ch .. "-HoldTarget"] and self.Inputs[ch .. "-HoldTarget"].Value > 0 then - return true - end - return false +function ENT:IsOnHold(ch, tab) + local inputs = tab.Inputs + local ch_string = ch .. "-HoldTarget" + + return inputs[ch_string] and inputs[ch_string].Value > 0 end @@ -390,47 +471,47 @@ function ENT:OnRemove() BaseClass.OnRemove(self) -- unpaint all our targets - if self.PaintTarget then - for _,ent in pairs(self.SelectedTargets) do - self:TargetPainter(ent, false) + local tab = self:GetTable() + + if tab.PaintTarget then + for _, ent in pairs(tab.SelectedTargets) do + tab.TargetPainter(self, ent, false, tab) end end end function ENT:OnRestore() BaseClass.OnRestore(self) - self.MaxTargets = self.MaxTargets or 1 end -function ENT:TargetPainter( tt, targeted ) - local ply = self:GetPlayer() - if tt and IsValid(tt) and tt:EntIndex() ~= 0 and ply:IsValid() and WireLib.CanTool(ply, tt, "colour") then - if (targeted) then - self.OldColor = tt:GetColor() +function ENT:TargetPainter(tt, targeted, tab) + local ply = tab.GetPlayer(self) + + if IsValid(tt) and not tt:IsEFlagSet(EFL_SERVER_ONLY) and ply:IsValid() and WireLib.CanTool(ply, tt, "colour") then + if targeted then + tab.OldColor = tt:GetColor() tt:SetColor(Color(255, 0, 0, 255)) else - if not self.OldColor then self.OldColor = Color(255,255,255,255) end + local color = tt:GetColor() - local c = tt:GetColor() + -- Do not change color back if the target color changed in the meantime + if color.r ~= 255 or color.g ~= 0 or color.b ~= 0 or color.a ~= 255 then + tab.OldColor = color + end - -- do not change color back if the target color changed in the meantime - if c.r ~= 255 or c.g ~= 0 or c.b ~= 0 or c.a ~= 255 then - self.OldColor = c + if not tab.OldColor then + tab.OldColor = Color(255, 255, 255) end - tt:SetColor(self.OldColor) + tt:SetColor(tab.OldColor) end end end -function ENT:ShowOutput(value) - local txt = "No Target" - if value then - txt = "Target Acquired" - end - +function ENT:PrepareOverlayData() + local txt = self.SelectedTargets[1] and "Target Acquired" or "No Target" if self.Inputs.Hold and (self.Inputs.Hold.Value > 0) then txt = txt .. " - Locked" end self:SetOverlayText(txt) From f731caeaa10c5fb273d44e942f40bdcbf8514094 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:05:08 +0300 Subject: [PATCH 02/12] Fix syntax error --- lua/entities/gmod_wire_target_finder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 81839f4839..459f4717e0 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -248,7 +248,7 @@ function ENT:FindColor(contact, tab) end function ENT:CheckTheBuddyList(ply, tab) - if not CPPI or not tab.CheckBuddyList return true end + if not CPPI or not tab.CheckBuddyList then return true end local ply = tab.GetPlayer(self) if not ply:IsValid() then return false end From e5cdde00a8e36d9cc9c2e57b5b70fd5f1e2a280e Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:08:33 +0300 Subject: [PATCH 03/12] Styling --- lua/entities/gmod_wire_target_finder.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 459f4717e0..4e29bc2f73 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -204,7 +204,7 @@ function ENT:SelectorNext(ch) if not selected_targets_sel[ch] then selected_targets_sel[ch] = 1 end local sel = selected_targets_sel[ch] - if (sel > bogeys) then sel = 1 end + if sel > bogeys then sel = 1 end local paint_target = tab.PaintTarget local selected_targets = tab.SelectedTargets @@ -397,7 +397,7 @@ function ENT:Think() tab.TargetPainter(self, selected_targets[i], false, tab) end - if (#bogeys > 0) then + if #bogeys > 0 then selected_targets[i] = table.remove(bogeys, 1) if paint_target then @@ -430,7 +430,7 @@ function ENT:IsTargeted(bogey, bogeynum, tab) for i = 1, max_range do local target = selected_targets[i] - if target and (target == bogey) then + if target and target == bogey then -- hold this target local i_string = i .. "-HoldTarget" @@ -512,7 +512,7 @@ end function ENT:PrepareOverlayData() local txt = self.SelectedTargets[1] and "Target Acquired" or "No Target" - if self.Inputs.Hold and (self.Inputs.Hold.Value > 0) then txt = txt .. " - Locked" end + if self.Inputs.Hold and self.Inputs.Hold.Value > 0 then txt = txt .. " - Locked" end self:SetOverlayText(txt) end From afb2c74ad2070281172bf866f0b0b57dc4623438 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:14:22 +0300 Subject: [PATCH 04/12] More styling + don't use deprecated WireLib functions --- lua/entities/gmod_wire_target_finder.lua | 168 +++++++++++------------ 1 file changed, 83 insertions(+), 85 deletions(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 4e29bc2f73..410e09370c 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -1,17 +1,15 @@ AddCSLuaFile() -DEFINE_BASECLASS( "base_wire_entity" ) -ENT.PrintName = "Wire Target Finder" +DEFINE_BASECLASS("base_wire_entity") + +ENT.PrintName = "Wire Target Finder" ENT.WireDebugName = "Target Finder" -if CLIENT then return end -- No more client +if CLIENT then return end function ENT:Initialize() - self:PhysicsInit( SOLID_VPHYSICS ) - self:SetMoveType( MOVETYPE_VPHYSICS ) - self:SetSolid( SOLID_VPHYSICS ) - - self.Inputs = Wire_CreateInputs(self, { "Hold", "Ignore [ARRAY]" }) - self.Outputs = WireLib.CreateSpecialOutputs( self, { "Out" }, { "ENTITY" } ) + self:PhysicsInit(SOLID_VPHYSICS) + WireLib.CreateInputs(self, {"Hold", "Ignore [ARRAY]"}) + WireLib.CreateSpecialOutputs(self, {"Out"}, {"ENTITY"}) end local MaxBogeys = GetConVar("wire_target_finders_maxbogeys") @@ -21,67 +19,67 @@ function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrust -- For dupe support local tab = self:GetTable() - table.Merge( tab, { - range = maxrange, - players = players, - npcs = npcs, - npcname = npcname, - beacons = beacons, - hoverballs = hoverballs, - thrusters = thrusters, - props = props, - propmodel = propmodel, - vehicles = vehicles, - playername = playername, - steamname = steamidfilter, - colorcheck = colorcheck, + table.Merge(tab, { + range = maxrange, + players = players, + npcs = npcs, + npcname = npcname, + beacons = beacons, + hoverballs = hoverballs, + thrusters = thrusters, + props = props, + propmodel = propmodel, + vehicles = vehicles, + playername = playername, + steamname = steamidfilter, + colorcheck = colorcheck, colortarget = colortarget, - pcolR = pcolR, - pcolG = pcolG, - pcolB = pcolB, - pcolA = pcolA, - casesen = casesen, - rpgs = rpgs, + pcolR = pcolR, + pcolG = pcolG, + pcolB = pcolB, + pcolA = pcolA, + casesen = casesen, + rpgs = rpgs, painttarget = painttarget, - minrange = minrange, - maxtargets = maxtargets, - maxbogeys = maxbogeys, - notargetowner = notargetowner, - notownersstuff = notownersstuff, - checkbuddylist = checkbuddylist, - onbuddylist = onbuddylist, - entity = entity, - } ) - - tab.MaxRange = maxrange - tab.MinRange = minrange or 1 - tab.TargetPlayer = players - tab.NoTargetOwner = notargetowner + minrange = minrange, + maxtargets = maxtargets, + maxbogeys = maxbogeys, + notargetowner = notargetowner, + notownersstuff = notownersstuff, + checkbuddylist = checkbuddylist, + onbuddylist = onbuddylist, + entity = entity, + }) + + tab.MaxRange = maxrange + tab.MinRange = minrange or 1 + tab.TargetPlayer = players + tab.NoTargetOwner = notargetowner tab.NoTargetOwnersStuff = notownersstuff - tab.TargetNPC = npcs - tab.NPCName = npcname - tab.TargetBeacon = beacons - tab.TargetHoverballs = hoverballs - tab.TargetThrusters = thrusters - tab.TargetProps = props - tab.PropModel = propmodel - tab.TargetVehicles = vehicles - tab.PlayerName = playername - tab.SteamName = steamidfilter - tab.ColorCheck = colorcheck - tab.ColorTarget = colortarget - tab.PcolR = pcolR - tab.PcolG = pcolG - tab.PcolB = pcolB - tab.PcolA = pcolA - tab.CaseSen = casesen - tab.TargetRPGs = rpgs - tab.EntFil = entity - tab.CheckBuddyList = checkbuddylist - tab.OnBuddyList = onbuddylist - tab.PaintTarget = painttarget - tab.MaxTargets = math.floor(math.Clamp(maxtargets or 1, 1, MaxTargets:GetInt())) - tab.MaxBogeys = math.floor(math.Clamp(maxbogeys or 1, tab.MaxTargets, MaxBogeys:GetInt())) + tab.TargetNPC = npcs + tab.NPCName = npcname + tab.TargetBeacon = beacons + tab.TargetHoverballs = hoverballs + tab.TargetThrusters = thrusters + tab.TargetProps = props + tab.PropModel = propmodel + tab.TargetVehicles = vehicles + tab.PlayerName = playername + tab.SteamName = steamidfilter + tab.ColorCheck = colorcheck + tab.ColorTarget = colortarget + tab.PcolR = pcolR + tab.PcolG = pcolG + tab.PcolB = pcolB + tab.PcolA = pcolA + tab.CaseSen = casesen + tab.TargetRPGs = rpgs + tab.EntFil = entity + tab.CheckBuddyList = checkbuddylist + tab.OnBuddyList = onbuddylist + tab.PaintTarget = painttarget + tab.MaxTargets = math.floor(math.Clamp(maxtargets or 1, 1, MaxTargets:GetInt())) + tab.MaxBogeys = math.floor(math.Clamp(maxbogeys or 1, tab.MaxTargets, MaxBogeys:GetInt())) if (tab.SelectedTargets) then -- Unpaint before clearing for _, ent in pairs(tab.SelectedTargets) do @@ -125,7 +123,7 @@ function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrust table.insert(AdjInputs, "Hold") table.insert(AdjInputs, "Ignore [ARRAY]") - Wire_AdjustInputs(self, AdjInputs) + WireLib.AdjustInputs(self, AdjInputs) end function ENT:TriggerInput(name, value) @@ -160,7 +158,7 @@ function ENT:GetBeaconPos(sensor) if selected then if not selected:IsValid() then selected_targets[ch] = nil - Wire_TriggerOutput(self, tostring(ch), 0) + WireLib.TriggerOutput(self, tostring(ch), 0) return sensor:GetPos() end @@ -184,7 +182,7 @@ function ENT:GetBeaconVelocity(sensor) if selected then if not selected:IsValid() then selected_targets[ch] = nil - Wire_TriggerOutput(self, tostring(ch), 0) + WireLib.TriggerOutput(self, tostring(ch), 0) return sensor:GetVelocity() end @@ -229,8 +227,8 @@ function ENT:SelectorNext(ch) tab.Inputs[ch .. "-HoldTarget"].Value = 1 local ch_string = tostring(ch) - Wire_TriggerOutput(self, ch_string, 1) - Wire_TriggerOutput(self, ch_string .. "_Ent", selected_targets[ch]) + WireLib.TriggerOutput(self, ch_string, 1) + WireLib.TriggerOutput(self, ch_string .. "_Ent", selected_targets[ch]) end end @@ -333,11 +331,11 @@ function ENT:Think() ((not no_target_owner or (class == "player") or (WireLib.GetOwner(contact) ~= tab.GetPlayer(self))) and -- NPCs ((target_npc and (contact:IsNPC()) and (isOneOf(class, npc_name))) or - --Players + -- Players (target_player and (class == "player") and CheckPlayers(self, contact, tab) or - --Locators + -- Locators (target_beacon and (class == "gmod_wire_locator")) or - --RPGs + -- RPGs (target_rpgs and (class == "rpg_missile")) or -- Hoverballs (target_hoverballs and (class == "gmod_hoverball" or class == "gmod_wire_hoverball")) or @@ -351,7 +349,7 @@ function ENT:Think() (ent_filter ~= "" and isOneOf(class, ent_filter))))) then if (contact:GetPos():Distance(pos) >= min_range) then - -- put targets in a table index by the distance from the finder + -- Put targets in a table index by the distance from the finder ndists = ndists + 1 bogeys[dist] = contact dists[ndists] = dist @@ -359,7 +357,7 @@ function ENT:Think() end end - -- sort the list of bogeys by key (distance) + -- Sort the list of bogeys by key (distance) tab.Bogeys = {} tab.InRange = {} table.sort(dists) @@ -379,7 +377,7 @@ function ENT:Think() end end - -- check that the selected targets are valid + -- Check that the selected targets are valid local max_targets = tab.MaxTargets local paint_target = tab.PaintTarget local selected_targets = tab.SelectedTargets @@ -404,12 +402,12 @@ function ENT:Think() tab.TargetPainter(self, selected_targets[i], true, tab) end - Wire_TriggerOutput(self, i_string, 1) - Wire_TriggerOutput(self, i_string .. "_Ent", selected_targets[i]) + WireLib.TriggerOutput(self, i_string, 1) + WireLib.TriggerOutput(self, i_string .. "_Ent", selected_targets[i]) else selected_targets[i] = nil - Wire_TriggerOutput(self, i_string, 0) - Wire_TriggerOutput(self, i_string .. "_Ent", NULL) + WireLib.TriggerOutput(self, i_string, 0) + WireLib.TriggerOutput(self, i_string .. "_Ent", NULL) end end end @@ -431,7 +429,7 @@ function ENT:IsTargeted(bogey, bogeynum, tab) local target = selected_targets[i] if target and target == bogey then - -- hold this target + -- Hold this target local i_string = i .. "-HoldTarget" if inputs[i_string] and inputs[i_string].Value > 0 then @@ -439,7 +437,7 @@ function ENT:IsTargeted(bogey, bogeynum, tab) return true end - -- this bogey is not as close as others, untarget it and let it be add back to the list + -- This bogey is not as close as others, untarget it and let it be add back to the list if bogeynum > max_range then selected_targets[i] = nil @@ -470,7 +468,7 @@ end function ENT:OnRemove() BaseClass.OnRemove(self) - -- unpaint all our targets + -- Unpaint all our targets local tab = self:GetTable() if tab.PaintTarget then From 29964cd01ecc57cfea4239c4aa8e3b8b526d290c Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:15:35 +0300 Subject: [PATCH 05/12] Woops --- lua/entities/gmod_wire_target_finder.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 410e09370c..d5d577ac47 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -134,7 +134,6 @@ function ENT:TriggerInput(name, value) for _, ent in ipairs(value) do ignored_hash[ent] = true end - else local select_next = self.Selector.Next From 7dd7af39f741e6d3553d3d1237d2774dc2eba839 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:15:49 +0300 Subject: [PATCH 06/12] More minor styling --- lua/entities/gmod_wire_target_finder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index d5d577ac47..3334ee0703 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -1,6 +1,6 @@ AddCSLuaFile() -DEFINE_BASECLASS("base_wire_entity") +DEFINE_BASECLASS("base_wire_entity") ENT.PrintName = "Wire Target Finder" ENT.WireDebugName = "Target Finder" From eb3bc446ffc080a6f2fd052031ffc868062eb459 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:21:44 +0300 Subject: [PATCH 07/12] Fixes --- lua/entities/gmod_wire_target_finder.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 3334ee0703..a0ac1cd7ea 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -110,7 +110,7 @@ function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrust local AdjInputs = {} - for i = 1, self.MaxTargets do + for i = 1, tab.MaxTargets do local i_string = tostring(i) local inputnext = i_string .. "-NextTarget" local inputhold = i_string .. "-HoldTarget" @@ -135,9 +135,9 @@ function ENT:TriggerInput(name, value) ignored_hash[ent] = true end else - local select_next = self.Selector.Next + local select_next = self.Selector.Next[name] - if value > 0 and select_next[name] then + if value > 0 and select_next then self:SelectorNext(select_next) end end @@ -201,7 +201,7 @@ function ENT:SelectorNext(ch) if not selected_targets_sel[ch] then selected_targets_sel[ch] = 1 end local sel = selected_targets_sel[ch] - if sel > bogeys then sel = 1 end + if sel > #bogeys then sel = 1 end local paint_target = tab.PaintTarget local selected_targets = tab.SelectedTargets @@ -247,10 +247,10 @@ end function ENT:CheckTheBuddyList(ply, tab) if not CPPI or not tab.CheckBuddyList then return true end - local ply = tab.GetPlayer(self) - if not ply:IsValid() then return false end + local owner = tab.GetPlayer(self) + if not owner:IsValid() then return false end - local friends = ply:CPPIGetFriends() + local friends = owner:CPPIGetFriends() if istable(friends) then for _, friend in pairs(friends) do @@ -418,13 +418,13 @@ function ENT:Think() end function ENT:IsTargeted(bogey, bogeynum, tab) - local max_range = tab.MaxTargets + local max_targets = tab.MaxTargets local paint_target = tab.PaintTarget local selected_targets = tab.SelectedTargets local in_range = tab.InRange local inputs = tab.Inputs - for i = 1, max_range do + for i = 1, max_targets do local target = selected_targets[i] if target and target == bogey then @@ -437,7 +437,7 @@ function ENT:IsTargeted(bogey, bogeynum, tab) end -- This bogey is not as close as others, untarget it and let it be add back to the list - if bogeynum > max_range then + if bogeynum > max_targets then selected_targets[i] = nil if paint_target then From 7a9b5c4a3fa70a1a2ecc313043131e09a21d8c68 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:23:06 +0300 Subject: [PATCH 08/12] Fix CheckPlayers --- lua/entities/gmod_wire_target_finder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index a0ac1cd7ea..b786f6c875 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -287,7 +287,7 @@ local function CheckPlayers(self, contact, tab) if tab.SteamName:Trim() ~= "" then local contact_steamid, contact_steamid64 = contact:SteamID(), contact:SteamID64() - if not isOneOf(contact_steamid, tab.SteamName, tab.CaseSen) or isOneOf(contact_steamid64, tab.SteamName, tab.CaseSen) then + if not isOneOf(contact_steamid, tab.SteamName, tab.CaseSen) or not isOneOf(contact_steamid64, tab.SteamName, tab.CaseSen) then return false end end From 1be3c73e826fc4d5493bf74706bef58ddc5f8adb Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:25:14 +0300 Subject: [PATCH 09/12] Im braindead --- lua/entities/gmod_wire_target_finder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index b786f6c875..57f91608fd 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -287,7 +287,7 @@ local function CheckPlayers(self, contact, tab) if tab.SteamName:Trim() ~= "" then local contact_steamid, contact_steamid64 = contact:SteamID(), contact:SteamID64() - if not isOneOf(contact_steamid, tab.SteamName, tab.CaseSen) or not isOneOf(contact_steamid64, tab.SteamName, tab.CaseSen) then + if not (isOneOf(contact_steamid, tab.SteamName, tab.CaseSen) or isOneOf(contact_steamid64, tab.SteamName, tab.CaseSen)) then return false end end From d19ef5a6a3af714eef2de0efbbf5298537e7b537 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:29:43 +0300 Subject: [PATCH 10/12] Fix nil error --- lua/entities/gmod_wire_target_finder.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 57f91608fd..89c883d4ee 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -347,7 +347,9 @@ function ENT:Think() -- Entity classnames (ent_filter ~= "" and isOneOf(class, ent_filter))))) then - if (contact:GetPos():Distance(pos) >= min_range) then + local dist = contact:GetPos():Distance(pos) + + if dist >= min_range then -- Put targets in a table index by the distance from the finder ndists = ndists + 1 bogeys[dist] = contact From d95b901bb5455b7edd6be3244939db990f6b0d64 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:41:37 +0300 Subject: [PATCH 11/12] Fix broken finding --- lua/entities/gmod_wire_target_finder.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index 89c883d4ee..ea71d74c57 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -364,12 +364,12 @@ function ENT:Think() table.sort(dists) local k = 1 - local bogeys = tab.Bogeys + local ent_bogeys = tab.Bogeys local max_bogeys = tab.MaxBogeys for i, d in ipairs(dists) do if not tab.IsTargeted(self, bogeys[d], i, tab) then - bogeys[k] = bogeys[d] + ent_bogeys[k] = bogeys[d] k = k + 1 if k > max_bogeys then @@ -396,8 +396,8 @@ function ENT:Think() tab.TargetPainter(self, selected_targets[i], false, tab) end - if #bogeys > 0 then - selected_targets[i] = table.remove(bogeys, 1) + if #ent_bogeys > 0 then + selected_targets[i] = table.remove(ent_bogeys, 1) if paint_target then tab.TargetPainter(self, selected_targets[i], true, tab) From a3bcceda63dc3ff8ee53c5ac5c36ddca09ce3dfa Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 4 Aug 2026 02:38:10 +0300 Subject: [PATCH 12/12] More minor changes --- lua/entities/gmod_wire_target_finder.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lua/entities/gmod_wire_target_finder.lua b/lua/entities/gmod_wire_target_finder.lua index ea71d74c57..c5a6b9ba3c 100644 --- a/lua/entities/gmod_wire_target_finder.lua +++ b/lua/entities/gmod_wire_target_finder.lua @@ -81,7 +81,7 @@ function ENT:Setup(maxrange, players, npcs, npcname, beacons, hoverballs, thrust tab.MaxTargets = math.floor(math.Clamp(maxtargets or 1, 1, MaxTargets:GetInt())) tab.MaxBogeys = math.floor(math.Clamp(maxbogeys or 1, tab.MaxTargets, MaxBogeys:GetInt())) - if (tab.SelectedTargets) then -- Unpaint before clearing + if tab.SelectedTargets then -- Unpaint before clearing for _, ent in pairs(tab.SelectedTargets) do tab.TargetPainter(self, ent, false, tab) end @@ -266,7 +266,7 @@ end -- Like the old FindInValue but without string.find() and for multiple values split by either a space or a comma. local function isOneOf(value, values_str, case_sensitive) if not isstring(value) or not isstring(values_str) then return false end - if values_str == "" then return true end -- why :/ + if values_str == "" then return true end -- Why :/ if not case_sensitive then value = value:lower() @@ -489,26 +489,25 @@ function ENT:TargetPainter(tt, targeted, tab) if IsValid(tt) and not tt:IsEFlagSet(EFL_SERVER_ONLY) and ply:IsValid() and WireLib.CanTool(ply, tt, "colour") then if targeted then - tab.OldColor = tt:GetColor() - tt:SetColor(Color(255, 0, 0, 255)) + tab.WireTargetOldColor = tt:GetColor() + tt:SetColor(Color(255, 0, 0)) else local color = tt:GetColor() -- Do not change color back if the target color changed in the meantime if color.r ~= 255 or color.g ~= 0 or color.b ~= 0 or color.a ~= 255 then - tab.OldColor = color + tab.WireTargetOldColor = color end - if not tab.OldColor then - tab.OldColor = Color(255, 255, 255) + if not tab.WireTargetOldColor then + tab.WireTargetOldColor = Color(255, 255, 255) end - tt:SetColor(tab.OldColor) + tt:SetColor(tab.WireTargetOldColor) end end end - function ENT:PrepareOverlayData() local txt = self.SelectedTargets[1] and "Target Acquired" or "No Target" if self.Inputs.Hold and self.Inputs.Hold.Value > 0 then txt = txt .. " - Locked" end