From 0fc6d621b1c2a88593ab4234de4de013fe2d38cc Mon Sep 17 00:00:00 2001 From: deltamolfar Date: Thu, 22 Aug 2024 21:36:30 +0300 Subject: [PATCH] Fix e:removeTrails() --- .../gmod_wire_expression2/core/entity.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index d83fb8076b..21d3d842ac 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -845,13 +845,22 @@ local function validateCanTrail(self, ent) if not isOwner(self, ent) then return self:throw("You do not own this entity!", nil) end end +local function removeTrail(self, ent) + local PlayerSteamID = self.player:SteamID() + if not trailedEntsAmount[PlayerSteamID] then return end + if not trailedEntsAmount[PlayerSteamID][ent] then return end + + trailedEntsAmount[PlayerSteamID][ent] = nil + duplicator.EntityModifiers.trail(self.player, ent, nil) +end + local function setTrail(self, ent, Data) local PlayerSteamID = self.player:SteamID() if not trailedEntsAmount[PlayerSteamID] then trailedEntsAmount[PlayerSteamID] = {} end - -- Removing a trail + -- Removing a trail (just in case) if Data == nil then - trailedEntsAmount[PlayerSteamID][ent] = nil + removeTrail(self, ent) return end @@ -870,7 +879,7 @@ __e2setcost(50) --- Removes the trail from . e2function void entity:removeTrails() validateCanTrail(self, this) - setTrail(self, this, nil) + removeTrail(self, this) end __e2setcost(75) @@ -917,7 +926,7 @@ e2function void entity:setTrails(startSize, endSize, length, string material, ve setTrail(self, this, Data) end -__e2setcost(5) +__e2setcost(10) [nodiscard] e2function number trailsLeft() @@ -929,6 +938,8 @@ e2function number trailsCount() return table.Count(trailedEntsAmount[self.player:SteamID()]) end +__e2setcost(5) + [nodiscard] e2function number trailsMax() return wire_expression2_entity_trails_max:GetInt()