Garry's Mod Wiki

duplicator.Paste

  table, table duplicator.Paste( Player Player, table EntityList, table ConstraintList )

Description

"Given entity list and constraint list, create all entities and return their tables"

Calls duplicator.CreateEntityFromTable on each sub-table of EntityList. If an entity is actually created, it calls ENTITY:OnDuplicated with the entity's duplicator data, then duplicator.ApplyEntityModifiers, duplicator.ApplyBoneModifiers and finally ENTITY:PostEntityPaste is called.

The constraints are then created with duplicator.CreateConstraintFromTable.

Arguments

1 Player Player
The player who wants to create something
2 table EntityList
A table of duplicator data to create the entities from
3 table ConstraintList
A table of duplicator data to create the constraints from

Returns

1 table
List of created entities
2 table
List of created constraints

Example

Code used for a TOOL to copy duplication data on right click and paste it with its original info on left click.

function TOOL:LeftClick( trace ) if (SERVER) then duplicator.Paste(self:GetOwner(),Dupe.Entities,Dupe.Constraints) print("PASTED") end return true end function TOOL:RightClick( trace ) if (SERVER and IsValid(trace.Entity)) then Dupe = duplicator.Copy(trace.Entity) print("COPIED") end return true end