Skip to content
Open
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
11 changes: 8 additions & 3 deletions lua/advdupe2/sv_misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
local BuildDupeInfo = {}
Constraint.BuildDupeInfo = BuildDupeInfo

local Ent1, Ent2

Check warning on line 26 in lua/advdupe2/sv_misc.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: Ent2

Check warning on line 26 in lua/advdupe2/sv_misc.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: Ent1
if IsValid(Constraint.Ent) then
if Constraint.Ent:GetPhysicsObjectCount()>1 then
BuildDupeInfo.Ent1Ang = Constraint.Ent:GetAngles()
Expand Down Expand Up @@ -79,16 +79,21 @@
end
end

local function monitorConstraint(name)
local oldFunc = constraint[name]
constraint[name] = function(...)
local function replaceConstraintFunction(oldFunc)
return function(...)
local Constraint, b, c = oldFunc(...)
if Constraint and Constraint:IsValid() then
SavePositions(Constraint)
end
return Constraint, b, c
end
end

local function monitorConstraint(name)
local desc = duplicator.ConstraintType[name]
desc.Func = replaceConstraintFunction(desc.Func)
constraint[name] = replaceConstraintFunction(constraint[name])
end
monitorConstraint("AdvBallsocket")
monitorConstraint("Axis")
monitorConstraint("Ballsocket")
Expand Down
Loading