Revision Difference
Entity:SelectWeightedSequence#547971
<function name="SelectWeightedSequence" parent="Entity" type="classfunc">
<description>
Returns sequence ID corresponding to given activity ID.
Opposite of <page>Entity:GetSequenceActivity</page>.
Similar to <page>Entity:LookupSequence</page>.
See also <page>Entity:SelectWeightedSequenceSeeded</page>.
</description>
<realm>Shared</realm>
<args>
<arg name="act" type="number">The activity ID, see <page>Enums/ACT</page>.</arg>
</args>
<rets>
<ret name="" type="number">The sequence ID</ret>
</rets>
</function>
<example>
<description>Use this hook to check if the model has a certain ACT_* enumeration, and if it does, play it.</description>
<code>
local VModel = self.Owner:GetViewModel()
local VModel = self:GetOwner():GetViewModel()
if ( self:Clip1() == 0 and VModel:SelectWeightedSequence( ACT_VM_RELOAD_EMPTY ) ) then
local SEQ = self:LookupSequence( ACT_VM_RELOAD_EMPTY )
if ( SEQ == -1 ) then
print( "reload" )
local EnumToSeq = VModel:SelectWeightedSequence( ACT_VM_RELOAD )
-- Play the normal reload animation
VModel:SendViewModelMatchingSequence( EnumToSeq )
else
print( "reload empty" )
local EnumToSeq = VModel:SelectWeightedSequence( ACT_VM_RELOAD_EMPTY )
-- Play the empty reload animation
VModel:SendViewModelMatchingSequence( EnumToSeq )
end
end
</code>
<output>Will play the ACT_VM_RELOAD_EMPTY enumeration if the model has it. If not, it will play the normal reload enum.</output>
</example>