Garry's Mod Wiki

duplicator.RegisterEntityClass

duplicator.RegisterEntityClass( string name, function function, vararg args )

Description

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.

Arguments

1 string name
The ClassName of the entity you wish to register a factory for
2 function function
The factory function you want to have called. It should have the arguments (Player, ...) where ... is whatever arguments you request to be passed.
3 vararg args
Strings of the names of arguments you want passed to function the from the Structures/EntityCopyData. As a special case, "Data" will pass the whole structure.

Example

Prints the datatable and then lets the duplicator do it's job

duplicator.RegisterEntityClass("prop_physics", function(ply, data) PrintTable(data) duplicator.GenericDuplicatorFunction(ply, data) end, "Data")
Output:
Skin = 0 Mins = -14.357550 -14.390250 -25.934851 Flex: ColGroup = 0 Pos = -292.415070 -157.575043 -12262.056641 PhysicsObjects: 0: Frozen = false Pos = 13.750092 0.490356 -4.675781 Angle = 0.057 87.808 -0.031 Class = prop_physics FlexScale = 1 Maxs = 14.438149 14.405550 25.995348 Model = models/props_borealis/bluebarrel001.mdl Angle = 0.057 134.318 -0.031

Page Links


Special Pages


Wikis

?

Render Time: 41ms

Session 0
DB GetPage 3
Generate Html 16
SaveChanges 8
Render Body 0
Render Sidebar 12