Accessing specific outfit animations via lua

  • #1, by F_KalThursday, 06. April 2017, 17:24 7 years ago
    Reading the Data Structure documentation, I'm unable to think of a way to reference some specific animation named anim1 that belongs to the current outfit of a character.

    for example I was looking for something like the following one (apparently it does not work, but you get the idea):

    If anim1 was a unique name, I could access it via the Animations[] table - but since there are various animations called anim1, (one for each outfit), how would one go about doing it?

    the idea is to have the same name for all the animations in all different outfits, and write functions that do not care about which outfit is currently active.

    Forum Fan

    107 Posts

  • #2, by afrlmeThursday, 06. April 2017, 17:52 7 years ago
    game.CurrentCharacter.CurrentOutfit.OutfitCharacterAnimations["name of animation"]
    -- or...
    Characters["Tom"].CurrentOutfit.OutfitCharacterAnimations["name of animation"]

    alternatively, you could write a function to speed up the process if you like. wink
    -- add this to script section as a definition script
    function charAnim(c, a)
     if c == nil then c = game.CurrentCharacter:getName() end
     -- + --
     startAnimation( Characters[c].CurrentOutfit.OutfitCharacterAnimations[a] )

    to use that you could do something like this inside of an execute a script action part...
    charAnim(nil, "open_door") -- play open_door animation of current character

    example 2 usage...
    charAnim("Tom", "salute") -- play salute animation of Tom

    Hope this helps. wink


    7278 Posts

  • #3, by F_KalThursday, 06. April 2017, 19:09 7 years ago
    Christ, @AFRLme you are amazing! 

    And I, a total idiot! 
    I don't know how I missed the OutfitCharacterAnimations field under the Outfit... *Shame* *shame* *shame*

    Forum Fan

    107 Posts