From e7db6e01612591a379dd896bf75c7b93f52f3631 Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Wed, 8 Nov 2023 18:31:49 +0200 Subject: [PATCH] =?UTF-8?q?Cleanup:=20Brackets=20with=20double=20quotes=20?= =?UTF-8?q?to=20include=20structures=20(=20like=20wirem=E2=80=A6=20(#445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added: Brackets with double quotes to include structures ( like wiremod ) Converted: Global `constraints` and `serializable` to real globals * Update: Shove control stricture in the global setup table * Order by length and reduce spaces --- lua/advdupe2/sh_codec.lua | 4 +- lua/advdupe2/sv_clipboard.lua | 124 ++++++++++---------- lua/autorun/client/advdupe2_cl_init.lua | 8 +- lua/autorun/server/advdupe2_sv_init.lua | 20 ++-- lua/entities/gmod_contr_spawner/cl_init.lua | 2 +- lua/entities/gmod_contr_spawner/init.lua | 5 +- lua/weapons/gmod_tool/stools/advdupe2.lua | 2 +- 7 files changed, 81 insertions(+), 84 deletions(-) diff --git a/lua/advdupe2/sh_codec.lua b/lua/advdupe2/sh_codec.lua index 86207b11..854a36cc 100644 --- a/lua/advdupe2/sh_codec.lua +++ b/lua/advdupe2/sh_codec.lua @@ -11,8 +11,8 @@ local REVISION = 5 AdvDupe2.CodecRevision = REVISION -include "sh_codec_legacy.lua" -AddCSLuaFile "sh_codec_legacy.lua" +include( "sh_codec_legacy.lua" ) +AddCSLuaFile( "sh_codec_legacy.lua" ) local pairs = pairs local type = type diff --git a/lua/advdupe2/sv_clipboard.lua b/lua/advdupe2/sv_clipboard.lua index 6a2dab50..2aa85894 100644 --- a/lua/advdupe2/sv_clipboard.lua +++ b/lua/advdupe2/sv_clipboard.lua @@ -5,7 +5,7 @@ Version: 1.0 ]] -require "duplicator" +require( "duplicator" ) AdvDupe2.duplicator = {} @@ -15,27 +15,63 @@ AdvDupe2.JobManager.Queue = {} local debugConvar = GetConVar("AdvDupe2_DebugInfo") -local constraints = { - Weld = true, - Axis = true, - Ballsocket = true, - Elastic = true, - Hydraulic = true, - Motor = true, - Muscle = true, - Pulley = true, - Rope = true, - Slider = true, - Winch = true -} - -local serializable = { - [TYPE_BOOL] = true, - [TYPE_NUMBER] = true, - [TYPE_VECTOR] = true, - [TYPE_ANGLE] = true, - [TYPE_TABLE] = true, - [TYPE_STRING] = true +local gtSetupTable = { + SERIAL = { + [TYPE_BOOL] = true, + [TYPE_ANGLE] = true, + [TYPE_TABLE] = true, + [TYPE_NUMBER] = true, + [TYPE_VECTOR] = true, + [TYPE_STRING] = true + }, + CONSTRAINT = { + Weld = true, + Axis = true, + Rope = true, + Motor = true, + Winch = true, + Muscle = true, + Pulley = true, + Slider = true, + Elastic = true, + Hydraulic = true, + Ballsocket = true + }, + COMPARE = { + V1 = Vector(1, 1, 1), + A0 = Angle (0, 0, 0), + V0 = Vector(0, 0, 0) + }, + POS = { + ["pos"] = true, + ["Pos"] = true, + ["position"] = true, + ["Position"] = true + }, + ANG = { + ["ang"] = true, + ["Ang"] = true, + ["angle"] = true, + ["Angle"] = true + }, + MODEL = { + ["model"] = true, + ["Model"] = true + }, + PLAYER = { + ["pl"] = true, + ["ply"] = true + }, + ENT1 = { + ["Ent"] = true, + ["Ent1"] = true, + }, + TVEHICLE = { + ["VehicleTable"] = true + }, + SPECIAL = { + ["Data"] = true + } } local function CopyClassArgTable(tab) @@ -45,7 +81,7 @@ local function CopyClassArgTable(tab) done[oldtable] = newtable for k, v in pairs(oldtable) do local varType = TypeID(v) - if serializable[varType] then + if gtSetupTable.SERIAL[varType] then if varType == TYPE_TABLE then if done[v] then newtable[k] = done[v] @@ -77,44 +113,6 @@ end Returns a copy of the passed entity's table ---------------------------------------------------------]] -local gtSetupTable = { - POS = { - ["pos" ] = true, - ["position"] = true, - ["Pos" ] = true, - ["Position"] = true - }, - ANG = { - ["ang" ] = true, - ["angle" ] = true, - ["Ang" ] = true, - ["Angle" ] = true - }, - MODEL = { - ["model" ] = true, - ["Model" ] = true - }, - PLAYER = { - ["pl" ] = true, - ["ply" ] = true - }, - ENT1 = { - ["Ent" ] = true, - ["Ent1" ] = true, - }, - COMPARE = { - V1 = Vector(1, 1, 1), - A0 = Angle (0, 0, 0), - V0 = Vector(0, 0, 0) - }, - TVEHICLE = { - ["VehicleTable"] = true - }, - SPECIAL = { - ["Data"] = true - } -} - function AdvDupe2.duplicator.IsCopyable(Ent) return not Ent.DoNotDuplicate and duplicator.IsAllowed(Ent:GetClass()) and IsValid(Ent:GetPhysicsObject()) end @@ -144,7 +142,7 @@ local function CopyEntTable(Ent, Offset) not gtSetupTable.ANG[Key] and not gtSetupTable.MODEL[Key]) then local varType = TypeID(EntTable[Key]) - if serializable[varType] then + if gtSetupTable.SERIAL[varType] then if varType == TYPE_TABLE then Tab[Key] = CopyClassArgTable(EntTable[Key]) else @@ -1381,7 +1379,7 @@ local function AdvDupe2_Spawn() v:SetParent(Queue.CreatedEntities[Queue.EntityList[k].BuildDupeInfo.DupeParentID]) if (v.Constraints ~= nil) then for i, c in pairs(v.Constraints) do - if (c and constraints[c.Type]) then + if (c and gtSetupTable.CONSTRAINT[c.Type]) then edit = false break end diff --git a/lua/autorun/client/advdupe2_cl_init.lua b/lua/autorun/client/advdupe2_cl_init.lua index 45f12284..dd3a30a3 100644 --- a/lua/autorun/client/advdupe2_cl_init.lua +++ b/lua/autorun/client/advdupe2_cl_init.lua @@ -11,10 +11,10 @@ if(!file.Exists(AdvDupe2.DataFolder, "DATA"))then file.CreateDir(AdvDupe2.DataFolder) end -include "advdupe2/file_browser.lua" -include "advdupe2/sh_codec.lua" -include "advdupe2/cl_file.lua" -include "advdupe2/cl_ghost.lua" +include( "advdupe2/file_browser.lua" ) +include( "advdupe2/sh_codec.lua" ) +include( "advdupe2/cl_file.lua" ) +include( "advdupe2/cl_ghost.lua" ) function AdvDupe2.Notify(msg,typ,dur) surface.PlaySound(typ == 1 and "buttons/button10.wav" or "ambient/water/drip1.wav") diff --git a/lua/autorun/server/advdupe2_sv_init.lua b/lua/autorun/server/advdupe2_sv_init.lua index 5b0931ff..f59af9f7 100644 --- a/lua/autorun/server/advdupe2_sv_init.lua +++ b/lua/autorun/server/advdupe2_sv_init.lua @@ -17,11 +17,11 @@ function AdvDupe2.Notify(ply,msg,typ, showsvr, dur) end end -AddCSLuaFile "autorun/client/advdupe2_cl_init.lua" -AddCSLuaFile "advdupe2/file_browser.lua" -AddCSLuaFile "advdupe2/sh_codec.lua" -AddCSLuaFile "advdupe2/cl_file.lua" -AddCSLuaFile "advdupe2/cl_ghost.lua" +AddCSLuaFile( "autorun/client/advdupe2_cl_init.lua" ) +AddCSLuaFile( "advdupe2/file_browser.lua" ) +AddCSLuaFile( "advdupe2/sh_codec.lua" ) +AddCSLuaFile( "advdupe2/cl_file.lua" ) +AddCSLuaFile( "advdupe2/cl_ghost.lua" ) util.AddNetworkString("AdvDupe2_ReportClass") util.AddNetworkString("AdvDupe2_ReportModel") @@ -120,9 +120,9 @@ hook.Add("PlayerInitialSpawn","AdvDupe2_AddPlayerTable",function(ply) ply.AdvDupe2 = {} end) -include "advdupe2/sv_clipboard.lua" -include "advdupe2/sh_codec.lua" -include "advdupe2/sv_misc.lua" -include "advdupe2/sv_file.lua" -include "advdupe2/sv_ghost.lua" +include( "advdupe2/sv_clipboard.lua" ) +include( "advdupe2/sh_codec.lua" ) +include( "advdupe2/sv_misc.lua" ) +include( "advdupe2/sv_file.lua" ) +include( "advdupe2/sv_ghost.lua" ) diff --git a/lua/entities/gmod_contr_spawner/cl_init.lua b/lua/entities/gmod_contr_spawner/cl_init.lua index a2eab731..9696702b 100644 --- a/lua/entities/gmod_contr_spawner/cl_init.lua +++ b/lua/entities/gmod_contr_spawner/cl_init.lua @@ -1,4 +1,4 @@ -include("shared.lua") +include( "shared.lua" ) function ENT:Draw() self.BaseClass.Draw(self) diff --git a/lua/entities/gmod_contr_spawner/init.lua b/lua/entities/gmod_contr_spawner/init.lua index 12438d2c..213ce770 100644 --- a/lua/entities/gmod_contr_spawner/init.lua +++ b/lua/entities/gmod_contr_spawner/init.lua @@ -8,14 +8,13 @@ Version: 1.0 ]] - AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) if(WireLib)then - include('entities/base_wire_entity.lua') + include( "entities/base_wire_entity.lua" ) end -include('shared.lua') +include( "shared.lua" ) function ENT:Initialize() diff --git a/lua/weapons/gmod_tool/stools/advdupe2.lua b/lua/weapons/gmod_tool/stools/advdupe2.lua index de62ef22..8496f5a7 100644 --- a/lua/weapons/gmod_tool/stools/advdupe2.lua +++ b/lua/weapons/gmod_tool/stools/advdupe2.lua @@ -10,7 +10,7 @@ TOOL.Category = "Construction" TOOL.Name = "#Tool.advdupe2.name" cleanup.Register( "AdvDupe2" ) -require "controlpanel" +require( "controlpanel" ) if(SERVER)then CreateConVar("sbox_maxgmod_contr_spawners",5)