From c1332e9dde1e5c249e398c68902cbd0e071e1819 Mon Sep 17 00:00:00 2001 From: Haze_of_dream <74027566+Hazeofdream@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:22:23 -0500 Subject: [PATCH 1/8] Implement ConVars --- lua/entities/gmod_wire_turret.lua | 10 ++++++---- lua/wire/stools/turret.lua | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lua/entities/gmod_wire_turret.lua b/lua/entities/gmod_wire_turret.lua index 0266d6293c..75029b82c9 100644 --- a/lua/entities/gmod_wire_turret.lua +++ b/lua/entities/gmod_wire_turret.lua @@ -5,6 +5,10 @@ ENT.WireDebugName = "Turret" if ( CLIENT ) then return end -- No more client +local NumEnabled = CreateConVar("wire_turret_numbullets_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or Disable the numbullets function of wire turrets") +CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or disable the tracer pe x bullet function of wire turrets") +local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.01, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Set the minimum allowed value for wire turrets") + function ENT:Initialize() self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) @@ -114,13 +118,11 @@ function ENT:SetSound( sound ) end function ENT:SetDelay( delay ) - local check = game.SinglePlayer() -- clamp delay if it's not single player - local limit = check and 0.01 or 0.05 - self.delay = math.Clamp( delay, limit, 1 ) + self.delay = math.Clamp( delay, MinTurretDelay, 1 ) end function ENT:SetNumBullets( numbullets ) - local check = game.SinglePlayer() -- clamp num bullets if it's not single player + local check = NumEnabled:GetBool() local limit = math.floor( math.max( 1, numbullets ) ) self.numbullets = check and limit or math.Clamp( limit, 1, 10 ) end diff --git a/lua/wire/stools/turret.lua b/lua/wire/stools/turret.lua index aae338e3bb..d9e86eae18 100644 --- a/lua/wire/stools/turret.lua +++ b/lua/wire/stools/turret.lua @@ -86,7 +86,7 @@ function TOOL.BuildCPanel( CPanel ) CPanel:AddControl("ComboBox", TracerType ) -- Various controls that you should play with! - if game.SinglePlayer() then + if GetConVar("wire_turret_numbullets_enabled"):GetBool() then CPanel:NumSlider("#Tool_wire_turret_numbullets", "wire_turret_numbullets", 1, 10, 0) end CPanel:NumSlider("#Damage", "wire_turret_damage", 0, 100, 0) @@ -94,11 +94,12 @@ function TOOL.BuildCPanel( CPanel ) CPanel:NumSlider("#Tool_wire_turret_force", "wire_turret_force", 0, 500, 1) -- The delay between shots. - if game.SinglePlayer() then - CPanel:NumSlider("#Delay", "wire_turret_delay", 0.01, 1.0, 2) + if GetConVar("wire_turret_tracer_enabled"):GetBool() then CPanel:NumSlider("#Tool_wire_turret_tracernum", "wire_turret_tracernum", 0, 15, 0) - else - CPanel:NumSlider("#Delay", "wire_turret_delay", 0.05, 1.0, 2) end + CPanel:NumSlider("#Delay", "wire_turret_delay", GetConVar("wire_turret_delay_minimum"):GetBool(), 1.0, 2) + + + end From a18443f137542590c177bc09a4b2a8da25c1f4ee Mon Sep 17 00:00:00 2001 From: Haze_of_dream <74027566+Hazeofdream@users.noreply.github.com> Date: Sun, 30 Jul 2023 18:34:05 -0500 Subject: [PATCH 2/8] Update turret.lua --- lua/wire/stools/turret.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wire/stools/turret.lua b/lua/wire/stools/turret.lua index d9e86eae18..8e7c01c701 100644 --- a/lua/wire/stools/turret.lua +++ b/lua/wire/stools/turret.lua @@ -98,7 +98,7 @@ function TOOL.BuildCPanel( CPanel ) CPanel:NumSlider("#Tool_wire_turret_tracernum", "wire_turret_tracernum", 0, 15, 0) end - CPanel:NumSlider("#Delay", "wire_turret_delay", GetConVar("wire_turret_delay_minimum"):GetBool(), 1.0, 2) + CPanel:NumSlider("#Delay", "wire_turret_delay", GetConVar("wire_turret_delay_minimum"):GetFloat(), 1.0, 2) From 13bfc20f002f8c5a8091dcd991e58e249192b3bb Mon Sep 17 00:00:00 2001 From: Haze_of_dream <74027566+Hazeofdream@users.noreply.github.com> Date: Sun, 30 Jul 2023 18:37:06 -0500 Subject: [PATCH 3/8] fix value --- lua/entities/gmod_wire_turret.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_turret.lua b/lua/entities/gmod_wire_turret.lua index 75029b82c9..6b250d4fc3 100644 --- a/lua/entities/gmod_wire_turret.lua +++ b/lua/entities/gmod_wire_turret.lua @@ -7,7 +7,7 @@ if ( CLIENT ) then return end -- No more client local NumEnabled = CreateConVar("wire_turret_numbullets_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or Disable the numbullets function of wire turrets") CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or disable the tracer pe x bullet function of wire turrets") -local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.01, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Set the minimum allowed value for wire turrets") +local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.05, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Set the minimum allowed value for wire turrets") function ENT:Initialize() self:PhysicsInit( SOLID_VPHYSICS ) From bd6ed446c7c9ab89b3b3b5afeee38ae18aea716f Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Mon, 31 Jul 2023 16:21:17 -0400 Subject: [PATCH 4/8] Update turret.lua --- lua/wire/stools/turret.lua | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lua/wire/stools/turret.lua b/lua/wire/stools/turret.lua index 8e7c01c701..e5f0ba1480 100644 --- a/lua/wire/stools/turret.lua +++ b/lua/wire/stools/turret.lua @@ -86,20 +86,11 @@ function TOOL.BuildCPanel( CPanel ) CPanel:AddControl("ComboBox", TracerType ) -- Various controls that you should play with! - if GetConVar("wire_turret_numbullets_enabled"):GetBool() then - CPanel:NumSlider("#Tool_wire_turret_numbullets", "wire_turret_numbullets", 1, 10, 0) - end + CPanel:NumSlider("#Tool_wire_turret_numbullets", "wire_turret_numbullets", 1, 10, 0) CPanel:NumSlider("#Damage", "wire_turret_damage", 0, 100, 0) CPanel:NumSlider("#Tool_wire_turret_spread", "wire_turret_spread", 0, 1.0, 2) CPanel:NumSlider("#Tool_wire_turret_force", "wire_turret_force", 0, 500, 1) - - -- The delay between shots. - if GetConVar("wire_turret_tracer_enabled"):GetBool() then - CPanel:NumSlider("#Tool_wire_turret_tracernum", "wire_turret_tracernum", 0, 15, 0) - end - - CPanel:NumSlider("#Delay", "wire_turret_delay", GetConVar("wire_turret_delay_minimum"):GetFloat(), 1.0, 2) - - + CPanel:NumSlider("#Tool_wire_turret_tracernum", "wire_turret_tracernum", 0, 15, 0) + CPanel:NumSlider("#Delay", "wire_turret_delay", 0, 1.0, 2) end From 131b98d20ff8293663ae941045d6112fbd6f8de7 Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Mon, 31 Jul 2023 16:26:00 -0400 Subject: [PATCH 5/8] Update gmod_wire_turret.lua --- lua/entities/gmod_wire_turret.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lua/entities/gmod_wire_turret.lua b/lua/entities/gmod_wire_turret.lua index 6b250d4fc3..30a2523f5c 100644 --- a/lua/entities/gmod_wire_turret.lua +++ b/lua/entities/gmod_wire_turret.lua @@ -5,9 +5,9 @@ ENT.WireDebugName = "Turret" if ( CLIENT ) then return end -- No more client -local NumEnabled = CreateConVar("wire_turret_numbullets_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or Disable the numbullets function of wire turrets") -CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or disable the tracer pe x bullet function of wire turrets") -local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.05, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Set the minimum allowed value for wire turrets") +local NumEnabled = CreateConVar("wire_turret_numbullets_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or Disable the numbullets function of wire turrets") +local TracerEnabled = CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or disable the tracer pe x bullet function of wire turrets") +local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.05, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Set the minimum allowed value for wire turrets") function ENT:Initialize() self:PhysicsInit( SOLID_VPHYSICS ) @@ -118,7 +118,7 @@ function ENT:SetSound( sound ) end function ENT:SetDelay( delay ) - self.delay = math.Clamp( delay, MinTurretDelay, 1 ) + self.delay = math.Clamp( delay, MinTurretDelay:GetFloat(), 1 ) end function ENT:SetNumBullets( numbullets ) @@ -128,8 +128,7 @@ function ENT:SetNumBullets( numbullets ) end function ENT:SetTracer( tracer ) - local tracer = string.Trim(tracer) - self.tracer = ValidTracers[tracer] and tracer or "" + self.tracer = TracerEnabled:GetBool() and ValidTracers[tracer] and string.Trim(tracer) or "" end function ENT:SetSpread( spread ) @@ -147,7 +146,7 @@ function ENT:SetForce( force ) end function ENT:SetTraceNum( tracernum ) - self.tracernum = math.floor( math.max( tracernum or 1 ) ) + self.tracernum = TracerEnabled:GetBool() and math.floor( math.max( tracernum or 1 ) ) or 0 end function ENT:TriggerInput( iname, value ) From da9d80e89384141ce183ec974e12aec2d1a00361 Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Mon, 31 Jul 2023 16:29:46 -0400 Subject: [PATCH 6/8] Update gmod_wire_turret.lua --- lua/entities/gmod_wire_turret.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/entities/gmod_wire_turret.lua b/lua/entities/gmod_wire_turret.lua index 30a2523f5c..c89e6c9a84 100644 --- a/lua/entities/gmod_wire_turret.lua +++ b/lua/entities/gmod_wire_turret.lua @@ -118,17 +118,16 @@ function ENT:SetSound( sound ) end function ENT:SetDelay( delay ) - self.delay = math.Clamp( delay, MinTurretDelay:GetFloat(), 1 ) + self.delay = math.Clamp( delay, MinTurretDelay:GetFloat(), 2 ) end function ENT:SetNumBullets( numbullets ) - local check = NumEnabled:GetBool() - local limit = math.floor( math.max( 1, numbullets ) ) - self.numbullets = check and limit or math.Clamp( limit, 1, 10 ) + self.numbullets = NumEnabled:GetBool() and math.Clamp( math.floor( numbullets ), 1, 10 ) or 1 end function ENT:SetTracer( tracer ) - self.tracer = TracerEnabled:GetBool() and ValidTracers[tracer] and string.Trim(tracer) or "" + tracer = string.Trim(tracer) + self.tracer = TracerEnabled:GetBool() and ValidTracers[tracer] and tracer or "" end function ENT:SetSpread( spread ) From bf025c981b478a3f624a997abeb36de0e0e74daf Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Mon, 31 Jul 2023 16:31:33 -0400 Subject: [PATCH 7/8] Update gmod_wire_turret.lua --- lua/entities/gmod_wire_turret.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_turret.lua b/lua/entities/gmod_wire_turret.lua index c89e6c9a84..27172a0d95 100644 --- a/lua/entities/gmod_wire_turret.lua +++ b/lua/entities/gmod_wire_turret.lua @@ -145,7 +145,7 @@ function ENT:SetForce( force ) end function ENT:SetTraceNum( tracernum ) - self.tracernum = TracerEnabled:GetBool() and math.floor( math.max( tracernum or 1 ) ) or 0 + self.tracernum = TracerEnabled:GetBool() and math.Clamp( math.floor( tracernum ), 0, 15 ) or 0 end function ENT:TriggerInput( iname, value ) From fd216c1790e537a19a21f1ba1e8d599e4a5d60ae Mon Sep 17 00:00:00 2001 From: Haze_of_dream <74027566+Hazeofdream@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:39:34 -0500 Subject: [PATCH 8/8] spelling error --- lua/entities/gmod_wire_turret.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_turret.lua b/lua/entities/gmod_wire_turret.lua index 27172a0d95..8daf0826d0 100644 --- a/lua/entities/gmod_wire_turret.lua +++ b/lua/entities/gmod_wire_turret.lua @@ -6,7 +6,7 @@ ENT.WireDebugName = "Turret" if ( CLIENT ) then return end -- No more client local NumEnabled = CreateConVar("wire_turret_numbullets_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or Disable the numbullets function of wire turrets") -local TracerEnabled = CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or disable the tracer pe x bullet function of wire turrets") +local TracerEnabled = CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or disable the tracer per x bullet function of wire turrets") local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.05, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Set the minimum allowed value for wire turrets") function ENT:Initialize()