Garry's Mod Wiki

Entity:IsValidLayer

  boolean Entity:IsValidLayer( number layerID )

Description

Returns whether the given layer ID is valid and exists on this entity.

This function only works on BaseAnimatingOverlay entities.

Arguments

1 number layerID
The Layer ID

Returns

1 boolean
Whether the given layer ID is valid and exists on this entity.

Example

Print information about an entity's all possible active layers.

local MAX_OVERLAYS = 15 -- defined in BaseAnimatingOverlay.h#L132 local queryEnt = Entity(1) for i = 0,MAX_OVERLAYS do -- overlay index starts from 0 up to 15 if queryEnt:IsValidLayer(i) then s = queryEnt:GetLayerSequence(i) print(i,s,queryEnt:GetSequenceName(s),queryEnt:GetSequenceActivityName(s)) end end
Output:
0 355 reload_revolver ACT_HL2MP_GESTURE_RELOAD_REVOLVER 2 249 jump_land ACT_LAND