From 803f72fde58468ef275a4fdb5b1dff8eaa75bb01 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:55:18 -0400 Subject: [PATCH 1/2] Fix linter complaints --- lua/acf/entities/racks/racks.lua | 2 +- .../entities/sensors/receivers/receivers.lua | 14 ++++---- lua/effects/acf_glatgmexplosion.lua | 26 +++++++------- lua/entities/acf_rack/cl_init.lua | 36 +++++++++---------- lua/entities/acf_radar/cl_init.lua | 20 +++++------ lua/entities/acf_radar/init.lua | 6 ++-- lua/entities/acf_receiver/init.lua | 14 ++++---- 7 files changed, 59 insertions(+), 59 deletions(-) diff --git a/lua/acf/entities/racks/racks.lua b/lua/acf/entities/racks/racks.lua index f85b5712..8b03128a 100644 --- a/lua/acf/entities/racks/racks.lua +++ b/lua/acf/entities/racks/racks.lua @@ -140,7 +140,7 @@ Racks.Register("4x AGM-114", { MountPoints = { { Name = "missile1", Position = Vector(0, -7.85, 4.9), Direction = Vector(0, 0, -1) }, - { Name = "missile2", Position = Vector(0, 8.05,4.9), Direction = Vector(0, 0, -1) }, + { Name = "missile2", Position = Vector(0, 8.05, 4.9), Direction = Vector(0, 0, -1) }, { Name = "missile3", Position = Vector(0, -7.85, -13), Direction = Vector(0, 0, -1) }, { Name = "missile4", Position = Vector(0, 8.05, -13), Direction = Vector(0, 0, -1) } } diff --git a/lua/acf/entities/sensors/receivers/receivers.lua b/lua/acf/entities/sensors/receivers/receivers.lua index d5ab1e2c..8eaa59f6 100644 --- a/lua/acf/entities/sensors/receivers/receivers.lua +++ b/lua/acf/entities/sensors/receivers/receivers.lua @@ -19,7 +19,7 @@ do -- Laser Receiver local ReceiverOrigin = Receiver:LocalToWorld(Receiver.Origin) - for k,v in pairs(ACF.ActiveLasers) do + for k, v in pairs(ACF.ActiveLasers) do local Dir = k.Dir or k:GetForward() if v.Distance > 0 then Dir = (v.HitPos - v.Origin):GetNormalized() end @@ -27,13 +27,13 @@ do -- Laser Receiver end -- Wiremod laser pointer, because it's, you know, a laser - for _,ply in pairs(player.GetAll()) do + for _, ply in ipairs(player.GetAll()) do local Wep = ply:GetWeapon("laserpointer") if not IsValid(Wep) then continue end if Wep ~= ply:GetActiveWeapon() then continue end if Wep.Pointing then - local Las = {Dir = ply:EyeAngles():Forward(),Position = ply:EyePos(),Player = ply} + local Las = {Dir = ply:EyeAngles():Forward(), Position = ply:EyePos(), Player = ply} if Las.Dir:Dot((ReceiverOrigin - Las.Position):GetNormalized()) >= Receiver.Cone then Lasers[Las] = true end end @@ -47,8 +47,8 @@ do -- Laser Receiver TraceData.start = Start TraceData.endpos = End if IsValid(Source.Player) then - TraceData.filter = {Receiver,Source.Player} - else TraceData.filter = {Receiver,Source} end + TraceData.filter = {Receiver, Source.Player} + else TraceData.filter = {Receiver, Source} end return not TraceLine(TraceData).Hit end @@ -61,7 +61,7 @@ do -- Laser Receiver Mass = 25, Health = 10, Armor = 10, - Offset = Vector(0,0,3), + Offset = Vector(0, 0, 3), ThinkDelay = 0.25, Divisor = 2.5, -- Divisor (pre-floor) and then multiplier to give a choppy angle @@ -125,7 +125,7 @@ do -- Radar Receiver Mass = 25, Health = 10, Armor = 10, - Offset = Vector(0,0,6), + Offset = Vector(0, 0, 6), ThinkDelay = 0.5, Divisor = 30, -- Divisor (pre-floor) and then multiplier to give a choppy angle diff --git a/lua/effects/acf_glatgmexplosion.lua b/lua/effects/acf_glatgmexplosion.lua index 0eb364e7..447c837f 100644 --- a/lua/effects/acf_glatgmexplosion.lua +++ b/lua/effects/acf_glatgmexplosion.lua @@ -5,7 +5,7 @@ local Sounds = ACF.Utilities.Sounds function EFFECT:Init(Data) self.DirVec = Data:GetNormal() self.Origin = Data:GetOrigin() + self.DirVec * -15 - self.Radius = math.Clamp(Data:GetScale() * 0.042 ,0.1,10) + self.Radius = math.Clamp(Data:GetScale() * 0.042, 0.1, 10) self.Emitter = ParticleEmitter(self.Origin) self.ParticleMul = LocalPlayer():GetInfoNum("acf_cl_particlemul", 1) @@ -44,7 +44,7 @@ function EFFECT:Airburst() EF:SetEndSize(30 * Radius) EF:SetRoll(800) EF:SetRollDelta(math.random(-1, 1)) - EF:SetColor(255,255,255) + EF:SetColor(255, 255, 255) end local EI = 20 * Radius * Mult for E = 0, EI do @@ -59,7 +59,7 @@ function EFFECT:Airburst() EF:SetEndSize(0) EF:SetRoll(800) EF:SetRollDelta(math.random(-1, 1)) - EF:SetColor(255,255,255) + EF:SetColor(255, 255, 255) end end EI = 10 * Radius * Mult @@ -75,18 +75,18 @@ function EFFECT:Airburst() EF:SetEndSize(0) EF:SetRoll(800) EF:SetRollDelta(math.random(-1, 1)) - EF:SetColor(255,255,255) + EF:SetColor(255, 255, 255) end end local Angle = self.DirVec:Angle() - Angle:RotateAroundAxis(Angle:Forward(), math.random(1,300)) - local rv = math.random(20,40) * Mult + Angle:RotateAroundAxis(Angle:Forward(), math.random(1, 300)) + local rv = math.random(20, 40) * Mult for _ = 0, rv do Angle:RotateAroundAxis(Angle:Forward(), 360 / rv) EF = self.Emitter:Add("particle/smokesprites_000" .. math.random(1, 9), Origin) if EF then - EF:SetVelocity((Angle:Up() - self.DirVec * math.random(0.05,0.25)) * math.random(200,300) * Radius) - EF:SetDieTime(math.random(0.35,0.8)) + EF:SetVelocity((Angle:Up() - self.DirVec * math.random(0.05, 0.25)) * math.random(200, 300) * Radius) + EF:SetDieTime(math.random(0.35, 0.8)) EF:SetStartAlpha(100) EF:SetEndAlpha(0) EF:SetStartSize(15 * Radius) @@ -99,19 +99,19 @@ function EFFECT:Airburst() end local Spark = Emitter:Add("particles/flamelet" .. math.random(1, 5), self.Origin) if Spark then - Spark:SetVelocity((Angle:Up() - self.DirVec * math.random(-0.5,1)) * math.random(40,100) * Radius) + Spark:SetVelocity((Angle:Up() - self.DirVec * math.random(-0.5, 1)) * math.random(40, 100) * Radius) Spark:SetLifeTime(0) Spark:SetDieTime(math.Rand(2, 8) * self.Radius) Spark:SetStartAlpha(255) Spark:SetEndAlpha(20) - Spark:SetStartSize(math.random(2,4) * 0.2 * self.Radius) + Spark:SetStartSize(math.random(2, 4) * 0.2 * self.Radius) Spark:SetEndSize(0 * self.Radius) - Spark:SetStartLength(math.random(2,7) * 0.5 * self.Radius) + Spark:SetStartLength(math.random(2, 7) * 0.5 * self.Radius) Spark:SetEndLength(0) Spark:SetRoll(math.Rand(0, 360)) Spark:SetRollDelta(math.Rand(-0.2, 0.2)) Spark:SetAirResistance(10) - Spark:SetGravity(Vector(0,0,-400)) + Spark:SetGravity(Vector(0, 0, -400)) Spark:SetColor(200, 200, 200) Spark:SetCollide(true) Spark:SetBounce(0.2) @@ -145,7 +145,7 @@ function EFFECT:Airburst() AirBurst:SetEndSize(100 * Radius) AirBurst:SetRoll(math.Rand(150, 360)) AirBurst:SetRollDelta(math.Rand(-0.2, 0.2)) - AirBurst:SetAirResistance(math.random(70,120)) + AirBurst:SetAirResistance(math.random(70, 120)) AirBurst:SetGravity(Vector(math.random(-10, 10) * Radius, math.random(-10, 10) * Radius, 20)) AirBurst:SetColor(200, 200, 200) end diff --git a/lua/entities/acf_rack/cl_init.lua b/lua/entities/acf_rack/cl_init.lua index 1b233231..a5d64e0d 100644 --- a/lua/entities/acf_rack/cl_init.lua +++ b/lua/entities/acf_rack/cl_init.lua @@ -20,7 +20,7 @@ do -- Overlay/networking net.SendToServer() end - net.Receive("ACF.RequestRackInfo",function() + net.Receive("ACF.RequestRackInfo", function() local Rack = net.ReadEntity() if not IsValid(Rack) then return end @@ -45,19 +45,19 @@ do -- Overlay/networking Rack.MountPoints = {} if next(RackInfo.MountPoints) then - for _,T in ipairs(RackInfo.MountPoints) do - local Dir = Vector(1,0,0) + for _, T in ipairs(RackInfo.MountPoints) do + local Dir = Vector(1, 0, 0) Dir:Rotate(T.Ang) Rack.MountPoints[#Rack.MountPoints + 1] = {Index = T.Index, Pos = T.Pos, Dir = Dir} end end local CrateEnts = {} - for _,E in ipairs(CrateInfo) do + for _, E in ipairs(CrateInfo) do local Crate = Entity(E) if IsValid(Crate) then - local Col = ColorAlpha(Crate:GetColor(),25) + local Col = ColorAlpha(Crate:GetColor(), 25) CrateEnts[#CrateEnts + 1] = {Ent = Crate, Col = Col} end end @@ -71,9 +71,9 @@ do -- Overlay/networking -- icon16/joystick.png controller sprite local RadarSprite = Material("icon16/transmit.png") local JoystickMat = Material("icon16/joystick.png") - local RadarColor = Color(255,255,0,25) - local ControllerColor = Color(0,255,0,25) - local ForwardColor = Color(255,0,0) + local RadarColor = Color(255, 255, 0, 25) + local ControllerColor = Color(0, 255, 0, 25) + local ForwardColor = Color(255, 0, 0) function ENT:DrawOverlay() local SelfTbl = self:GetTable() @@ -86,18 +86,18 @@ do -- Overlay/networking end if next(SelfTbl.Crates) then - for _,T in ipairs(SelfTbl.Crates) do + for _, T in ipairs(SelfTbl.Crates) do local E = T.Ent if IsValid(E) then - render.DrawWireframeBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),T.Col,true) - render.DrawBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),T.Col) + render.DrawWireframeBox(E:GetPos(), E:GetAngles(), E:OBBMins(), E:OBBMaxs(), T.Col, true) + render.DrawBox(E:GetPos(), E:GetAngles(), E:OBBMins(), E:OBBMaxs(), T.Col) end end end if next(SelfTbl.MountPoints) then - for _,T in ipairs(SelfTbl.MountPoints) do + for _, T in ipairs(SelfTbl.MountPoints) do local Pos1 = self:LocalToWorld(T.Pos - T.Dir * 6) local Pos2 = self:LocalToWorld(T.Pos + T.Dir * 6) render.DrawBeam(Pos1, Pos2, 2, 0, 0, color_black) @@ -105,9 +105,9 @@ do -- Overlay/networking end cam.Start2D() - for _,T in ipairs(SelfTbl.MountPoints) do + for _, T in ipairs(SelfTbl.MountPoints) do local Pos = self:LocalToWorld(T.Pos):ToScreen() - draw.SimpleTextOutlined("Mount " .. T.Index,"ACF_Title",Pos.x,Pos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Mount " .. T.Index, "ACF_Title", Pos.x, Pos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) end cam.End2D() end @@ -115,8 +115,8 @@ do -- Overlay/networking if IsValid(SelfTbl.Radar) then local Radar = SelfTbl.Radar local RadPos, RadAng, OBBMin, OBBMax = Radar:GetPos(), Radar:GetAngles(), Radar:OBBMins(), Radar:OBBMaxs() - render.DrawWireframeBox(RadPos,RadAng,OBBMin,OBBMax,RadarColor,true) - render.DrawBox(RadPos,RadAng,OBBMin,OBBMax,RadarColor) + render.DrawWireframeBox(RadPos, RadAng, OBBMin, OBBMax, RadarColor, true) + render.DrawBox(RadPos, RadAng, OBBMin, OBBMax, RadarColor) render.SetMaterial(RadarSprite) render.DrawSprite(Radar:LocalToWorld(Radar:OBBCenter()), 12, 12, color_white) @@ -127,8 +127,8 @@ do -- Overlay/networking if IsValid(SelfTbl.Computer) then local Computer = SelfTbl.Computer local ComPos, ComAng, OBBMin, OBBMax = Computer:GetPos(), Computer:GetAngles(), Computer:OBBMins(), Computer:OBBMaxs() - render.DrawWireframeBox(ComPos,ComAng,OBBMin,OBBMax,ControllerColor,true) - render.DrawBox(ComPos,ComAng,OBBMin,OBBMax,ControllerColor) + render.DrawWireframeBox(ComPos, ComAng, OBBMin, OBBMax, ControllerColor, true) + render.DrawBox(ComPos, ComAng, OBBMin, OBBMax, ControllerColor) render.SetMaterial(JoystickMat) render.DrawSprite(Computer:LocalToWorld(Computer:OBBCenter()), 12, 12, color_white) diff --git a/lua/entities/acf_radar/cl_init.lua b/lua/entities/acf_radar/cl_init.lua index 0cf4d178..29df80bf 100644 --- a/lua/entities/acf_radar/cl_init.lua +++ b/lua/entities/acf_radar/cl_init.lua @@ -20,7 +20,7 @@ do -- Overlay/networking net.SendToServer() end - net.Receive("ACF.RequestRadarInfo",function() + net.Receive("ACF.RequestRadarInfo", function() local Radar = net.ReadEntity() if not IsValid(Radar) then return end @@ -37,8 +37,8 @@ do -- Overlay/networking Radar.Age = Clock.CurTime + 5 end) - local Col = Color(255,255,0,25) - local Col2 = Color(255,255,0) + local Col = Color(255, 255, 0, 25) + local Col2 = Color(255, 255, 0) function ENT:DrawOverlay() local SelfTbl = self:GetTable() @@ -51,17 +51,17 @@ do -- Overlay/networking local Origin = self:LocalToWorld(SelfTbl.Origin) if SelfTbl.Spherical then - render.DrawWireframeSphere(Origin,SelfTbl.Range,50,50,Col2) + render.DrawWireframeSphere(Origin, SelfTbl.Range, 50, 50, Col2) else for I = 0, 7 do - local Dir = Vector(16384,0,0) - Dir:Rotate(Angle(SelfTbl.Cone,0,0)) - Dir:Rotate(Angle(0,0,45 * I)) + local Dir = Vector(16384, 0, 0) + Dir:Rotate(Angle(SelfTbl.Cone, 0, 0)) + Dir:Rotate(Angle(0, 0, 45 * I)) local Point = self:LocalToWorld(SelfTbl.Origin + Dir) - local Dir2 = Vector(16384,0,0) - Dir2:Rotate(Angle(SelfTbl.Cone,0,0)) - Dir2:Rotate(Angle(0,0,45 * (I + 1))) + local Dir2 = Vector(16384, 0, 0) + Dir2:Rotate(Angle(SelfTbl.Cone, 0, 0)) + Dir2:Rotate(Angle(0, 0, 45 * (I + 1))) local Point2 = self:LocalToWorld(SelfTbl.Origin + Dir2) render.DrawQuad(Origin, Point, Point2, Point, Col) diff --git a/lua/entities/acf_radar/init.lua b/lua/entities/acf_radar/init.lua index e6348425..2f51783b 100644 --- a/lua/entities/acf_radar/init.lua +++ b/lua/entities/acf_radar/init.lua @@ -169,7 +169,7 @@ local function ScanForEntities(Entity) for Ent in pairs(Detected) do local EntPos = Ent.Position or Ent:GetPos() - if CheckLOS(Origin, EntPos) and (math.Rand(0,1) >= (EntDamage / 10)) then + if CheckLOS(Origin, EntPos) and (math.Rand(0, 1) >= (EntDamage / 10)) then local EntSpread = VectorRand(-Spread, Spread) local EntVel = Ent.Velocity or Ent:GetVelocity() local Owner = GetEntityOwner(Entity.Owner, Ent) @@ -559,14 +559,14 @@ end do -- Overlay/networking util.AddNetworkString("ACF.RequestRadarInfo") - net.Receive("ACF.RequestRadarInfo",function(_,Ply) + net.Receive("ACF.RequestRadarInfo", function(_, Ply) local Radar = net.ReadEntity() if not IsValid(Radar) then return end local RadarInfo = {} RadarInfo.Spherical = (Radar.ConeDegs == nil) and true or false RadarInfo.Cone = Radar.ConeDegs and math.Round(Radar.ConeDegs, 2) or 0 - RadarInfo.Range = Radar.Range and math.Round(Radar.Range,2) or 0 + RadarInfo.Range = Radar.Range and math.Round(Radar.Range, 2) or 0 RadarInfo.Origin = Radar.Origin net.Start("ACF.RequestRadarInfo") diff --git a/lua/entities/acf_receiver/init.lua b/lua/entities/acf_receiver/init.lua index 84a87a7c..cd8360bd 100644 --- a/lua/entities/acf_receiver/init.lua +++ b/lua/entities/acf_receiver/init.lua @@ -44,13 +44,13 @@ local function CheckReceive(Entity) for Ent in pairs(Sources) do local EntPos = Ent.Position or Ent:GetPos() local EntDamage = Entity.Damage - local Spread = math.max(Entity.Divisor,15) * 2 * EntDamage + local Spread = math.max(Entity.Divisor, 15) * 2 * EntDamage - if Entity.CheckLOS(Entity, Ent, Origin, EntPos) and (math.Rand(0,1) >= (EntDamage / 5)) then + if Entity.CheckLOS(Entity, Ent, Origin, EntPos) and (math.Rand(0, 1) >= (EntDamage / 5)) then IsDetected = true local PreAng = (EntPos - Origin):GetNormalized():Angle() - Ang = Angle(math.Round((PreAng.p + math.random(-Spread,Spread)) / Entity.Divisor),math.Round((PreAng.y + math.random(-Spread,Spread)) / Entity.Divisor),0) * Entity.Divisor + Ang = Angle(math.Round((PreAng.p + math.random(-Spread, Spread)) / Entity.Divisor), math.Round((PreAng.y + math.random(-Spread, Spread)) / Entity.Divisor), 0) * Entity.Divisor Dir = Ang:Forward() break -- Stop at the first valid source @@ -72,7 +72,7 @@ local function CheckReceive(Entity) WireLib.TriggerOutput(Entity, "Angle", Ang) end -local function SetActive(Entity,Bool) +local function SetActive(Entity, Bool) ResetOutputs(Entity) if Bool then @@ -220,7 +220,7 @@ do -- Spawn and Update functions CheckLegal(Receiver) - SetActive(Receiver,true) + SetActive(Receiver, true) return Receiver end @@ -303,13 +303,13 @@ end function ENT:Enable() if not CheckLegal(self) then return end - SetActive(self,true) + SetActive(self, true) self:UpdateOverlay() end function ENT:Disable() - SetActive(self,false) + SetActive(self, false) end local Text = "%s\n\n%s" From c97753da92d42ee6aa503a00c5cd53a960149602 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:00:30 -0400 Subject: [PATCH 2/2] Fix one more linter complaint --- lua/entities/acf_rack/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/acf_rack/init.lua b/lua/entities/acf_rack/init.lua index bd12a392..19d23029 100644 --- a/lua/entities/acf_rack/init.lua +++ b/lua/entities/acf_rack/init.lua @@ -794,7 +794,7 @@ do -- Overlay/networking RackInfo.MountPoints = {} - for _,Point in pairs(Rack.MountPoints) do + for _, Point in pairs(Rack.MountPoints) do RackInfo.MountPoints[#RackInfo.MountPoints + 1] = {Pos = Point.Position, Ang = Point.Angle, Index = Point.Index} end