Revision Difference
Entity:GetAnimInfo#546892
<function name="GetAnimInfo" parent="Entity" type="classfunc">
<description>
Returns a table containing the number of frames, flags, name, and FPS of an entity's animation ID.
<note>Animation ID is not the same as sequence ID.</note>⤶
<note>Animation ID is not the same as sequence ID. See <page>Entity:GetAnimCount</page></note>⤶
</description>
<realm>Shared</realm>
<args>
<arg name="animIndex" type="number">The animation ID to look up</arg>
</args>
<rets>
<ret name="" type="table">Information about the animation, or nil if the index is out of bounds</ret>
</rets>
</function>
<example>
<description>A function that finds an entity sequence's corresponding animation and returns the animation info.</description>
<code>
function GetAnimInfoSequence( ent, seq )
if( !IsValid( ent ) ) then return nil end
local seqname = ent:GetSequenceName( seq )
if( seqname == "Unknown" ) then return nil end
local info = nil
local done = ent:GetAnimInfo(0).label -- this is how we know when to stop
local i = 1
-- We don't want to increment too high or we will run into errors or possibly crashes
while(i < 1600) do -- arbitrary failsafe
info = ent:GetAnimInfo(i)
if(string.find(info.label, "@"..seqname) or string.find(info.label, "a_"..seqname)) then
return info
end
-- the first animation info is repeated when there are no animations left in the model
if(info.label == done) then break end
i = i + 1
end
return nil
end
</code>
</example>