Add constraint limit from basegame (#482)

* Add constraint limit from basegame

* Differentiate between rope and regular constraints

* Remove print

* Apply suggestions from code review

Co-authored-by: thegrb93 <grbrown93@sbcglobal.net>

* Add player check

---------

Co-authored-by: thegrb93 <grbrown93@sbcglobal.net>
This commit is contained in:
Redox 2024-10-31 02:13:49 +01:00 committed by GitHub
parent 8a1fa8658f
commit ac5f1f202a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -509,6 +509,7 @@ local function CreateConstraintFromTable(Constraint, EntityList, EntityTable, Pl
local Factory = duplicator.ConstraintType[Constraint.Type]
if not Factory then return end
if Player and not Player:CheckLimit( "constraints" ) then return end
local first, firstindex -- Ent1 or Ent in the constraint's table
local second, secondindex -- Any other Ent that is not Ent1 or Ent
local Args = {} -- Build the argument list for the Constraint's spawn function
@ -650,6 +651,10 @@ local function CreateConstraintFromTable(Constraint, EntityList, EntityTable, Pl
return
end
if Player then
Player:AddCount( "constraints", Ent )
end
Ent.BuildDupeInfo = table.Copy(buildInfo)
-- Move the entities back after constraining them. No point in moving the world though.