Revision Difference
Structures/PropertyAdd#526969
<cat>struct</cat>
<structure>
<description>Structure used for <page>properties.Add</page>.</description>
<fields>
<item name="Type" type="string" default="simple">Can be set to "toggle" to make this property a toggle property.</item>
<item name="MenuLabel" type="string">Label to show on opened menu</item>
<item name="MenuIcon" type="string">Icon to show on opened menu for this item. Optional for simple properties and unused for toggle properties.</item>
<item name="StructureField (Order)" type="number">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 |
| <page text="Edit Properties">Editable_Entities</page> | 90001 |
</item>
<item name="PrependSpacer" type="boolean" default="false">Whether to add a spacer before this property. This should generally be true for the first property in a group of properties.</item>
<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>.
</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
</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 self:MsgStart(), write data with the <page>net</page> 'Write' functions, and finish with self:MsgEnd(). 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>
<item name="Receive" type="function">
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
* <page>Player</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>.
</item>
<item name="MenuOpen" type="function">
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>DMenuOption</page> option - the menu option⤶
* <page>Entity</page> ent - the entity the player right-clicked
* <page>table</page> tr - the player's eye trace
</item>
<item name="OnCreate" type="function">
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? -->⤶
* <page>DMenu</page> menu - the property menu⤶
* <page>DMenuOption</page> option - the menu option⤶
</item>
</fields>
</structure>