Gamemode.TranslateActivity

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameTranslateActivity
SyntaxGM:TranslateActivity( Player ply, Act act )
DescriptionAnimation
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.TranslateActivity]Gamemode.TranslateActivity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionTranslates between animations
Used onNewerShared.png
Code
 
local IdleActivity = ACT_HL2MP_IDLE
local IdleActivityTranslate = {}
    IdleActivityTranslate [ ACT_MP_STAND_IDLE ]                 = IdleActivity
    IdleActivityTranslate [ ACT_MP_WALK ]                         = IdleActivity+1
    IdleActivityTranslate [ ACT_MP_RUN ]                         = IdleActivity+2
    IdleActivityTranslate [ ACT_MP_CROUCH_IDLE ]                 = IdleActivity+3
    IdleActivityTranslate [ ACT_MP_CROUCHWALK ]                 = IdleActivity+4
    IdleActivityTranslate [ ACT_MP_ATTACK_STAND_PRIMARYFIRE ]     = IdleActivity+5
    IdleActivityTranslate [ ACT_MP_ATTACK_CROUCH_PRIMARYFIRE ]    = IdleActivity+5
    IdleActivityTranslate [ ACT_MP_RELOAD_STAND ]                 = IdleActivity+6
    IdleActivityTranslate [ ACT_MP_RELOAD_CROUCH ]                 = IdleActivity+6
    IdleActivityTranslate [ ACT_MP_JUMP ]                         = ACT_HL2MP_JUMP_SLAM
 
// it is preferred you return ACT_MP_* in CalcMainActivity, and if you have a specific need to not tranlsate through the weapon do it here
function GM:TranslateActivity( ply, act )
    local act = act
    local newact = ply:TranslateWeaponActivity( act )
 
    // select idle anims if the weapon didn't decide
    if ( act == newact ) then
        return IdleActivityTranslate[ act ]
    else
        return newact
    end
end
 
 
OutputN/A

http://luabin.overvprojects.nl/?path=/gamemodes/base/gamemode/animations.lua

Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox