From 5235a2513cda9d7a7e990f0fd0c589f1013a96fe Mon Sep 17 00:00:00 2001 From: TwistedTail <8784231+TwistedTail@users.noreply.github.com> Date: Sat, 14 Oct 2023 02:33:34 -0300 Subject: [PATCH] Improved fuel tank verification - Now fuel tanks will properly make use of its verification function, along with allowing people to implement scalable and non scalable fuel tank classes into ACF. - Added Size to the list of dupe information arguments on fuel tanks. --- lua/entities/acf_fueltank/init.lua | 65 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index ddca9a48e..888819fc8 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -49,46 +49,45 @@ do -- Spawn and Update functions } local function VerifyData(Data) - if not isvector(Data.Size) then - local Group = Classes.GetGroup(FuelTanks, Data.FuelTank) - local Tank = FuelTanks.GetItem(Group.ID, Data.FuelTank) - - if Tank.Size then -- Updating pre-scalable update fuel tanks - Data.Size = Vector(Tank.Size) - Data.Shape = Tank.Shape - else - local X = ACF.CheckNumber(Data.TankSizeX, 24) - local Y = ACF.CheckNumber(Data.TankSizeY, 24) - local Z = ACF.CheckNumber(Data.TankSizeZ, 24) - - if Data.FuelTank == "Drum" then - Y = X - end - - Data.Size = Vector(X, Y, Z) - end + if not isstring(Data.FuelTank) then + Data.FuelTank = Data.SizeId or Data.Id end - do -- Clamping size - local Min = ACF.FuelMinSize - local Max = ACF.FuelMaxSize - local Size = Data.Size + local Class = Classes.GetGroup(FuelTanks, Data.FuelTank) - Size.x = math.Clamp(math.Round(Size.x), Min, Max) - Size.y = math.Clamp(math.Round(Size.y), Min, Max) - Size.z = math.Clamp(math.Round(Size.z), Min, Max) - end + if not Class then + Data.FuelTank = "Box" - if not Data.FuelTank then - Data.FuelTank = Data.SizeId or Data.Id or "Jerry_Can" + Class = FuelTanks.Get("Box") + elseif FuelTanks.IsAlias(Data.FuelTank) then + Data.FuelTank = Class.ID end - local Class = Classes.GetGroup(FuelTanks, Data.FuelTank) + if Class.IsScalable then + local FuelTank = FuelTanks.GetItem(Class.ID, Data.FuelTank) - if not Class then - Data.FuelTank = "Jerry_Can" + if FuelTank then + Data.FuelTank = Class.ID + Data.Size = Vector(FuelTank.Size) + elseif not isvector(Data.Size) then + local X = ACF.CheckNumber(Data.TankSizeX, 24) + local Y = ACF.CheckNumber(Data.TankSizeY, 24) + local Z = ACF.CheckNumber(Data.TankSizeZ, 24) - Class = Classes.GetGroup(FuelTanks, "Jerry_Can") + Data.Size = Vector(X, Y, Z) + end + + do -- Clamping size + local Min = ACF.FuelMinSize + local Max = ACF.FuelMaxSize + local Size = Data.Size + + Size.x = math.Clamp(math.Round(Size.x), Min, Max) + Size.y = math.Clamp(math.Round(Size.y), Min, Max) + Size.z = math.Clamp(math.Round(Size.z), Min, Max) + end + else + Data.Size = nil end -- Making sure to provide a valid fuel type @@ -263,7 +262,7 @@ do -- Spawn and Update functions return Tank end - Entities.Register("acf_fueltank", MakeACF_FuelTank, "FuelTank", "FuelType") + Entities.Register("acf_fueltank", MakeACF_FuelTank, "FuelTank", "FuelType", "Size") ACF.RegisterLinkSource("acf_fueltank", "Engines")