Revision Difference
Structures/PropertyAdd#517061
<cat>struct</cat>
<structure>
<description>Structure used for <page>properties.Add</page>.</description>
<fields>{{StructureField|string|Type|Can be set to "toggle" to make this property a toggle property.|"simple"</fields>
</structure>
⤶
{{StructureField|string|MenuLabel|Label to show on opened menu}}{{StructureField|string|MenuIcon|Icon to show on opened menu for this item. Optional for simple properties and unused for toggle properties.|nil}}{{StructureField|number|Order|Where in the list should the property be positioned, relative to other properties.⤶
⤶
<item name="MenuLabel" type="string">Label to show on opened menu</item>⤶
{{StructureField|string|MenuIcon|Icon to show on opened menu for this item. Optional for simple properties and unused for toggle properties.|nil}}{{StructureField|number|Order|Where in the list should the property be positioned, relative to other properties.⤶
For reference, here are the default properties and their Order values:
Property | Order |
---------|-------|
| Bone Manipulate | 500 |
| Bodygroups | 600 |
| Skin | 601 |
| Keep Upright | 900 |
| Ignite/Extinguish | 999 |
| Remove | 1000 |
| Gravity | 1001 |
| Drive | 1100 |
| Collision | 1500 |
| Statue | 1501 |
| NPC Biggify/Smallify | 1799, 1800 |
| Motion Control (Kinect) | 2500 |
| [Edit Properties](/gmod/Editable_Entities) | 90001 |
}}{{StructureField|boolean|PrependSpacer|Whether to add a spacer before this property. This should generally be true for the first property in a group of properties.|false}}{{StructureField|function|Filter|Used **clientside** to decide whether this property should be shown for an entity. Gets these arguments:
}}{{StructureField|boolean|PrependSpacer|Whether to add a spacer before this property. This should generally be true for the first property in a group of properties.|false}}<item name="Filter" type="function">Used **clientside** to decide whether this property should be shown for an entity. Gets these arguments:
* <page>table</page> self - the property table
* <page>Entity</page> ent - the entity the player clicked
Return true if the property should be shown for this entity. It's good practice to call <page>SANDBOX:CanProperty</page> in this hook via <page>gamemode.Call</page> or <page>hook.Run</page>.⤶
}}{{StructureField|function|Checked|Required for toggle properties (clientside). Must return a boolean value to either check or uncheck the toggle property.
Return true if the property should be shown for this entity. It's good practice to call <page>SANDBOX:CanProperty</page> in this hook via <page>gamemode.Call</page> or <page>hook.Run</page>.</item>⤶
<item name="Checked" type="function">Required for toggle properties (clientside). Must return a boolean value to either check or uncheck the toggle property.
* <page>table</page> self - the property table
* <page>Entity</page> ent - the entity the player clicked
* <page>table</page> tr - the player's eye trace⤶
}}{{StructureField|function|Action|Called **clientside** when the property is clicked with these arguments:
* <page>table</page> tr - the player's eye trace</item>⤶
<item name="Action" type="function">Called **clientside** when the property is clicked with these arguments:
* <page>table</page> self - the property table
* <page>Entity</page> ent - the entity the player clicked
* <page>table</page> tr - the player's eye trace
When appropriate, within this function you can call <kbd>self:MsgStart()</kbd>, write data with the <page>net</page> 'Write' functions, and finish with <kbd>self:MsgEnd()</kbd>. This will activate the 'Receive' function on the server. In most cases, you will want to send the entity to the server, as it's not done by default.⤶
}}{{StructureField|function|Receive|Called **serverside** if the client sends a message in the 'Action' function (see above).
When appropriate, within this function you can call <kbd>self:MsgStart()</kbd>, write data with the <page>net</page> 'Write' functions, and finish with <kbd>self:MsgEnd()</kbd>. This will activate the 'Receive' function on the server. In most cases, you will want to send the entity to the server, as it's not done by default.</item>⤶
{{StructureField|function|Receive|Called **serverside** if the client sends a message in the 'Action' function (see above).
* <page>table</page> self - the property table
* <page>number</page> len - the net message length, although this includes the property identifier used internally (the name of the property)
* <page>table</page> ply - the player who clicked the property
You can read data received from the client with the <page>net</page> 'Read' functions. It's good practice to check <page>SANDBOX:CanProperty</page> here via <page>gamemode.Call</page> or <page>hook.Run</page>.|nil
}}{{StructureField|function|MenuOpen|Called **clientside** when the property option has been created in the right-click menu. This is not called for toggle properties!
* <page>table</page> self - the property table
* <page>Panel</page> option - the menu option <!-- to do: what type of panel? -->
* <page>Entity</page> ent - the entity the player right-clicked
* <page>table</page> tr - the player's eye trace|nil
}}{{StructureField|function|OnCreate|Same as MenuOpen, but also called for toggle properties and has different arguments. This is called immediately after MenuOpen, but nothing happens in between so you should only ever use one or the other.
* <page>table</page> self - the property table
* <page>Panel</page> menu - the property menu <!-- to do: what type of panel? -->
* <page>Panel</page> option - the menu option <!-- to do: what type of panel? -->|nil
}}
}}