Garry's Mod Wiki
The duplicator library allows you to specify what should be saved when someone attempts to duplicate your custom entity with the duplicator tool. It can also be used by 3rd party duplicator tools to make use of the built in system.
Fields
table duplicator.BoneModifiers
A list of all entity bone modifiers registered with duplicator. RegisterBoneModifier.
table duplicator.ConstraintType
A list of all constraints that can be duplicated. Registered with duplicator. RegisterConstraint.
table duplicator.EntityClasses
A list of all entity classes have a custom duplication spawn function. Registered with duplicator. RegisterEntityClass.
If you wish to get a specific entity class table, use duplicator. FindEntityClass.
table duplicator.EntityModifiers
A list of all entity modifiers registered with duplicator. RegisterEntityModifier.
Methods
Allow entities with given class name to be duplicated. See duplicator. Disallow for the opposite effect.
Calls every function registered with duplicator. RegisterBoneModifier on each bone the ent has.
Calls every function registered with duplicator. RegisterEntityModifier on the entity.
Clears/removes the chosen entity modifier from the entity.
Copies the entity, and all of its constraints and entities, then returns them in a table.
Returns a table with some entity data that can be used to create a new entity with duplicator. CreateEntityFromTable
This is used internally - although you're able to use it you probably shouldn't.
Creates a constraint from a saved/copied constraint table.
"Create an entity from a table. "
This creates an entity using the data in EntTable.
If an entity factory has been registered for the entity's Class, it will be called.
Otherwise, duplicator. GenericDuplicatorFunction will be called instead.
Disallow this entity to be duplicated. Opposite of duplicator. Allow.
By default, all classes are disallowed to be duplicated. This function is useful for temporarily disabling duplication of certain entity classes that may have been previously allowed.
"Restores the bone's data. "
Loops through Bones and calls Entity:ManipulateBoneScale, Entity:ManipulateBoneAngles and Entity:ManipulateBonePosition on ent with the table keys and the subtable values s, a and p respectively.
Restores the flex data using Entity:SetFlexWeight and Entity:SetFlexScale
"Applies generic every-day entity stuff for ent from table data. "
Depending on the values of Model, Angle, Pos, Skin, Flex, Bonemanip, ModelScale, ColGroup, Name, and BodyG (table of multiple values) in the data table, this calls Entity:SetModel, Entity:SetAngles, Entity:SetPos, Entity:SetSkin, duplicator. DoFlex, duplicator. DoBoneManipulator, Entity:SetModelScale, Entity:SetCollisionGroup, Entity:SetName, Entity:SetBodygroup on ent.
If ent has a RestoreNetworkVars function, it is called with data. DT.
"Applies bone data, generically. "
If data contains a PhysicsObjects table, it moves, re-angles and if relevent freezes all specified bones, first converting from local coordinates to world coordinates.
duplicator.FigureOutRequiredAddons( table dupe )
Checks the given duplication table and tries to figure out any addons that might be required to correctly spawn the duplication. Currently this is limited to models and material overrides saved in the duplication.
Returns the entity class factory registered with duplicator. RegisterEntityClass.
"Generic function for duplicating stuff"
This is called when duplicator. CreateEntityFromTable can't find an entity factory to build with. It calls duplicator. DoGeneric and duplicator. DoGenericPhysics to apply standard duplicator stored things such as the model and position.
table, table duplicator.GetAllConstrainedEntitiesAndConstraints( Entity ent, table entStorageTable, table constraintStorageTable )
This is used internally - although you're able to use it you probably shouldn't.
Fills entStorageTable with all of the entities in a group connected with constraints. Fills constraintStorageTable with all of the constrains constraining the group.
"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.
Registers a function to be called on each of an entity's bones when duplicator. ApplyBoneModifiers is called.
This function is available to call on the client, but registered functions aren't used anywhere!
Register a function used for creating a duplicated constraint.
This allows you to specify a specific function to be run when your SENT is pasted with the duplicator, instead of relying on the generic automatic functions.
Automatically calls duplicator. Allow for the entity class.
This allows you to register tweaks to entities. For instance, if you were making an "unbreakable" addon, you would use this to enable saving the "unbreakable" state of entities between duplications.
This function registers a piece of generic code that is run on all entities with this modifier. In order to have it actually run, use duplicator. StoreEntityModifier.
This function does nothing when run clientside.
duplicator.RemoveMapCreatedEntities()
Help to remove certain map created entities before creating the saved entities
This is obviously so we don't get duplicate props everywhere.
It should be called before calling Paste.
duplicator.SetLocalAng( Angle v )
"When a copy is copied it will be translated according to these.
If you set them - make sure to set them back to 0 0 0!"
duplicator.SetLocalPos( Vector v )
"When a copy is copied it will be translated according to these.
If you set them - make sure to set them back to 0 0 0!"
Stores bone mod data for a registered bone modification function
Stores an entity modifier into an entity for saving
Works out the AABB size of the duplication
This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.
Page content is automatically updated twice a day. Edits and history are not available.
Last Parsed: Loading...