duplicator.Paste

From Garry's Mod
Jump to: navigation, search
 duplicator.Paste( )

Contents

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

Player Player

The player who wants to create something

Arguments

table EntityList

A table of duplicator data to create the entities from

Arguments

table ConstraintList

A table of duplicator data to create the constraints from

Returns

table

List of created entities

Returns

table

List of created constraints

Examples

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


Personal tools
Navigation