Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix e:removeTrails() #3128

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lua/entities/gmod_wire_expression2/core/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -870,7 +879,7 @@ __e2setcost(50)
--- Removes the trail from <this>.
e2function void entity:removeTrails()
validateCanTrail(self, this)
setTrail(self, this, nil)
removeTrail(self, this)
end

__e2setcost(75)
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Loading