constraint/GetAllConstrainedEntities

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (edit with form -> save; should fix page layout)
m (Add "view source" link)
 
Line 5: Line 5:
 
|Name=GetAllConstrainedEntities
 
|Name=GetAllConstrainedEntities
 
|Parent=constraint
 
|Parent=constraint
 +
|File=lua/includes/modules/constraint.lua
 +
|Line=1620
 
}}
 
}}
 
{{Arg
 
{{Arg

Latest revision as of 13:47, 10 April 2017

 constraint.GetAllConstrainedEntities( )

Contents

Description

Returns a table of all entities recursively constrained to an entitiy.

Arguments

Entity ent

The entity to check

Arguments

table ResultTable=nil

Table used to return result. Optional.

Returns

table

A table containing all of the constrained entities. This includes all entities constrained to entities constrained to the supplied entity, etc.

Examples

Example

Adapted from stools/remover.lua

-- Remove this entity and everything constrained
function TOOL:RightClick( trace )
	if ( !IsValid( trace.Entity ) or trace.Entity:IsPlayer() ) then return false end
	-- Loop through all the entities in the system
	for _, Entity in pairs( constraint.GetAllConstrainedEntities( trace.Entity ) ) do
		DoRemoveEntity( Entity )
	end
	return true
end


Personal tools
Navigation