Garry's Mod Wiki

Revision Difference

duplicator.RegisterEntityClass#515693

<function name="RegisterEntityClass" parent="duplicator" type="libraryfunc">⤶ <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.⤶ ⤶ <note>Automatically calls <page>duplicator.Allow</page> for the entity class.</note>⤶ </description>⤶ <realm>Shared</realm>⤶ <args>⤶ <arg name="name" type="string">The ClassName of the entity you wish to register a factory for</arg>⤶ <arg name="function" type="function">The factory function you want to have called. It should have the arguments (Player, ...) where ... is whatever arguments you request to be passed.</arg>⤶ <arg name="args" type="vararg">Strings of the names of arguments you want passed to function the from the &lt;page&gt;EntityCopyData&lt;/page&gt;. As a special case, &quot;Data&quot; will pass the whole structure.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Prints the datatable and then lets the duplicator do it's job</description>⤶ <code>⤶ duplicator.RegisterEntityClass("prop_physics", function(ply, data)⤶ PrintTable(data)⤶ duplicator.GenericDuplicatorFunction(ply, data)⤶ end, "Data")⤶ </code>⤶ <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⤶ ```⤶ ⤶ </output>⤶ ⤶ </example>