From 38de1342bf78a17e9a9c277ca5c02a78408b527c Mon Sep 17 00:00:00 2001 From: LengthenedGradient Date: Tue, 11 Feb 2025 23:53:15 -0500 Subject: [PATCH 1/4] Add Vehicle Inputs To Cam Controllers And EGP Huds Adds a "Vehicle" input to Cam Controllers and EGP Huds, inline with Pod Controllers. I understand this is somewhat redundant for Cam Controllers but I feel it's relevant. I am working on some addon stuff where a seat may not exist on spawn (generated by another entity). In this case, wire I/O is a reliable way to persist linkages through dupes. --- lua/entities/gmod_wire_cameracontroller.lua | 7 +++++++ lua/entities/gmod_wire_egp_hud/init.lua | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_cameracontroller.lua b/lua/entities/gmod_wire_cameracontroller.lua index e9eeafe0e4..a564146002 100644 --- a/lua/entities/gmod_wire_cameracontroller.lua +++ b/lua/entities/gmod_wire_cameracontroller.lua @@ -388,6 +388,7 @@ function ENT:Initialize() "FLIR", "FOV", "Vehicles (Links all vehicles of passed array to this cam controller) [ARRAY]", + "Vehicle [ENTITY]" }) self.Activated = false -- Whether or not to activate the cam controller for all players sitting in linked vehicles, or as soon as a player sits in a linked vehicle @@ -864,6 +865,12 @@ function ENT:TriggerInput( name, value ) if( not IsValid(v) ) then continue end self:LinkEnt( v ) end + elseif name == "Vehicle" then + if not IsValid(value) then return end -- Only link if the input is valid. That way, it won't be unlinked if the wire is disconnected + if value:IsPlayer() then return end + if value:IsNPC() then return end + + self:LinkEnt(value) else self:LocalizePositions(false) diff --git a/lua/entities/gmod_wire_egp_hud/init.lua b/lua/entities/gmod_wire_egp_hud/init.lua index c2eeeb893d..752d2edae6 100644 --- a/lua/entities/gmod_wire_egp_hud/init.lua +++ b/lua/entities/gmod_wire_egp_hud/init.lua @@ -25,7 +25,8 @@ function ENT:Initialize() self:AddEFlags( EFL_FORCE_CHECK_TRANSMIT ) WireLib.CreateInputs(self, { - "0 to 512 (If enabled, changes the resolution of the egp hud to be between 0 and 512 instead of the user's monitor's resolution.\nWill cause objects to look stretched out on most screens, so your UI will need to be designed with this in mind.\nIt's recommended to use the egpScrW, egpScrH, and egpScrSize functions instead.)" + "0 to 512 (If enabled, changes the resolution of the egp hud to be between 0 and 512 instead of the user's monitor's resolution.\nWill cause objects to look stretched out on most screens, so your UI will need to be designed with this in mind.\nIt's recommended to use the egpScrW, egpScrH, and egpScrSize functions instead.)", + "Vehicle [ENTITY]" }) WireLib.CreateOutputs(self, { "wirelink [WIRELINK]" }) @@ -42,6 +43,12 @@ end function ENT:TriggerInput( name, value ) if (name == "0 to 512") then self:SetResolution(value ~= 0) + elseif name == "Vehicle" then + if not IsValid(value) then return end -- Only link if the input is valid. That way, it won't be unlinked if the wire is disconnected + if value:IsPlayer() then return end + if value:IsNPC() then return end + + self:LinkEnt(value) end end From 96eb533f914d1f6da11bd941ab9d82f5db43f7cb Mon Sep 17 00:00:00 2001 From: LengthenedGradient Date: Wed, 12 Feb 2025 01:31:08 -0500 Subject: [PATCH 2/4] Add 'Vehichles' Input To Pod Controller And EGP Instead of adding 'Vehichle' to Cam Controllers and EGP --- lua/entities/gmod_wire_cameracontroller.lua | 7 ------- lua/entities/gmod_wire_egp_hud/init.lua | 14 +++++++------- lua/entities/gmod_wire_pod.lua | 9 ++++++++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lua/entities/gmod_wire_cameracontroller.lua b/lua/entities/gmod_wire_cameracontroller.lua index a564146002..e9eeafe0e4 100644 --- a/lua/entities/gmod_wire_cameracontroller.lua +++ b/lua/entities/gmod_wire_cameracontroller.lua @@ -388,7 +388,6 @@ function ENT:Initialize() "FLIR", "FOV", "Vehicles (Links all vehicles of passed array to this cam controller) [ARRAY]", - "Vehicle [ENTITY]" }) self.Activated = false -- Whether or not to activate the cam controller for all players sitting in linked vehicles, or as soon as a player sits in a linked vehicle @@ -865,12 +864,6 @@ function ENT:TriggerInput( name, value ) if( not IsValid(v) ) then continue end self:LinkEnt( v ) end - elseif name == "Vehicle" then - if not IsValid(value) then return end -- Only link if the input is valid. That way, it won't be unlinked if the wire is disconnected - if value:IsPlayer() then return end - if value:IsNPC() then return end - - self:LinkEnt(value) else self:LocalizePositions(false) diff --git a/lua/entities/gmod_wire_egp_hud/init.lua b/lua/entities/gmod_wire_egp_hud/init.lua index 752d2edae6..90ea840123 100644 --- a/lua/entities/gmod_wire_egp_hud/init.lua +++ b/lua/entities/gmod_wire_egp_hud/init.lua @@ -26,7 +26,7 @@ function ENT:Initialize() WireLib.CreateInputs(self, { "0 to 512 (If enabled, changes the resolution of the egp hud to be between 0 and 512 instead of the user's monitor's resolution.\nWill cause objects to look stretched out on most screens, so your UI will need to be designed with this in mind.\nIt's recommended to use the egpScrW, egpScrH, and egpScrSize functions instead.)", - "Vehicle [ENTITY]" + "Vehicles (Links all vehicles of passed array to this egp HUD) [ARRAY]", }) WireLib.CreateOutputs(self, { "wirelink [WIRELINK]" }) @@ -43,12 +43,12 @@ end function ENT:TriggerInput( name, value ) if (name == "0 to 512") then self:SetResolution(value ~= 0) - elseif name == "Vehicle" then - if not IsValid(value) then return end -- Only link if the input is valid. That way, it won't be unlinked if the wire is disconnected - if value:IsPlayer() then return end - if value:IsNPC() then return end - - self:LinkEnt(value) + elseif name == "Vehicles" then + for k, v in ipairs( value ) do + if( TypeID(v) ~= TYPE_ENTITY ) then continue end + if( not IsValid(v) ) then continue end + self:LinkEnt( v ) + end end end diff --git a/lua/entities/gmod_wire_pod.lua b/lua/entities/gmod_wire_pod.lua index 26639b4ba8..5c96582db4 100644 --- a/lua/entities/gmod_wire_pod.lua +++ b/lua/entities/gmod_wire_pod.lua @@ -163,7 +163,8 @@ function ENT:Initialize() "Disable", "Crosshairs", "Brake", "Allow Buttons", "Relative (If this is non-zero, the 'Bearing' and 'Elevation' outputs will be relative to the vehicle.)", "Damage Health (Damages the driver's health.)", "Damage Armor (Damages the driver's armor.)", "Hide Player", "Hide HUD", "Show Cursor", - "Vehicle [ENTITY]" + "Vehicle [ENTITY]", + "Vehicles (Links all vehicles of passed array to this pod controller) [ARRAY]", } self.Inputs = WireLib.CreateInputs(self, inputs) @@ -471,6 +472,12 @@ function ENT:TriggerInput(name, value) if value:IsNPC() then return end self:LinkEnt(value) + elseif name == "Vehicles" then + for k, v in ipairs( value ) do + if( TypeID(v) ~= TYPE_ENTITY ) then continue end + if( not IsValid(v) ) then continue end + self:LinkEnt( v ) + end end end From 9d4542217b9c35bd47a2e6c76cefd68aac19ec34 Mon Sep 17 00:00:00 2001 From: LengthenedGradient Date: Wed, 12 Feb 2025 18:28:51 -0500 Subject: [PATCH 3/4] Update gmod_wire_pod.lua --- lua/entities/gmod_wire_pod.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_pod.lua b/lua/entities/gmod_wire_pod.lua index 5c96582db4..c2dd19e79d 100644 --- a/lua/entities/gmod_wire_pod.lua +++ b/lua/entities/gmod_wire_pod.lua @@ -468,8 +468,8 @@ function ENT:TriggerInput(name, value) self:SetShowCursor(value) elseif name == "Vehicle" then if not IsValid(value) then return end -- Only link if the input is valid. That way, it won't be unlinked if the wire is disconnected - if value:IsPlayer() then return end - if value:IsNPC() then return end + if( TypeID(value) ~= TYPE_ENTITY ) then return end + if( not IsValid(value) ) then return end self:LinkEnt(value) elseif name == "Vehicles" then From 398539d154c1d31577f4bba76ea3c4423ba12a55 Mon Sep 17 00:00:00 2001 From: LengthenedGradient Date: Wed, 12 Feb 2025 21:04:02 -0500 Subject: [PATCH 4/4] Fix Redundant check removed. --- lua/entities/gmod_wire_pod.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/entities/gmod_wire_pod.lua b/lua/entities/gmod_wire_pod.lua index c2dd19e79d..0253717190 100644 --- a/lua/entities/gmod_wire_pod.lua +++ b/lua/entities/gmod_wire_pod.lua @@ -467,7 +467,6 @@ function ENT:TriggerInput(name, value) elseif name == "Show Cursor" then self:SetShowCursor(value) elseif name == "Vehicle" then - if not IsValid(value) then return end -- Only link if the input is valid. That way, it won't be unlinked if the wire is disconnected if( TypeID(value) ~= TYPE_ENTITY ) then return end if( not IsValid(value) ) then return end