Revision Difference
properties.Add#561919
<function name="Add" parent="properties" type="libraryfunc">
<description>Add properties to the properties module</description>⤶
<description>Add properties to the properties module. Properties can be blocked via <page>GM:CanProperty</page>.</description>⤶
<realm>Shared</realm>
<file line="28-L36">lua/includes/modules/properties.lua</file>
<args>
<arg name="name" type="string">A unique name used to identify the property</arg>
<arg name="propertyData" type="table">A table that defines the property. Uses the <page>Structures/PropertyAdd</page>.</arg>
</args>
</function>
<example>
<description>Defines a property that can be used to ignite entities (from Sandbox)</description>
<code>
properties.Add( "ignite", {
MenuLabel = "#ignite", -- Name to display on the context menu
Order = 999, -- The order to display this property relative to other properties
MenuIcon = "icon16/fire.png", -- The icon to display next to the property
Filter = function( self, ent, ply ) -- A function that determines whether an entity is valid for this property
if ( !IsValid( ent ) ) then return false end
if ( ent:IsPlayer() ) then return false end
if ( !CanEntityBeSetOnFire( ent ) ) then return false end
if ( !gamemode.Call( "CanProperty", ply, "ignite", ent ) ) then return false end
return !ent:IsOnFire()
end,
Action = function( self, ent ) -- The action to perform upon using the property ( Clientside )
self:MsgStart()
net.WriteEntity( ent )
self:MsgEnd()
end,
Receive = function( self, length, ply ) -- The action to perform upon using the property ( Serverside )
local ent = net.ReadEntity()
if ( !properties.CanBeTargeted( ent, ply ) ) then return end
if ( !self:Filter( ent, ply ) ) then return end
ent:Ignite( 360 )
end
} )
</code>
</example>