#how to preload animations and call them in another script

1 messages · Page 1 of 1 (latest)

ornate juniper
#

js need some ideas

weary atlas
#

Why

ornate juniper
#

i have lots of tool and have to switch between them fast

#

soi wanna preload the anims

weary atlas
#

But why call them in another scripts

ornate juniper
#

the tool scripts

#

im trying to preload them all in a single script so when i equip the tools it does have delays loading anims

tawdry magnet
weary atlas
#

Just do LoadAnim or something like this in each script in the beginning

#

Oh yeah

ornate juniper
ornate juniper
ornate juniper
tawdry magnet
#

You can use the module script to handle the animations

maiden viperBOT
#

studio** You are now Level 6! **studio

tawdry magnet
#

and call it in another script using methods

ornate juniper
#

i load all the animations by calling the module function, then add every loaded animation into a table and get an animation on the tool script as a variable?

burnt pawn
#

i do this in my game, here is an example (you'll have to add the code yourself)
`-- use CharacterAnimations[AnimationName] to index the track in any other script
local CharacterAnimations = {}

local animDictionary = {
AnimationName = 123456789
}

function CharacterAnimations:LoadAllOntoCharacter(char)
-- load them onto the Animator with a CharacterAdded event
end

return CharacterAnimations`

ornate juniper
#

without having to load again

burnt pawn
#

this module is just a table that happens to have a method in it (LoadAllOntoCharacter), so you just call the Track's name after adding it to the table in the method

#

in my example, after you load the track onto the character's animator, you would do CharacterAnimations[AnimationName] = AnimationTrackObject

ornate juniper
#

ah ok

#

i think i got it

burnt pawn
#

great, let me know if you have any more questions!

ornate juniper
#

if you dont mind, can tou teach me module methods

#

bc i only use modules for functions and tables

burnt pawn
#

i'm not suuper familiar with the lua internals, but from what I understand module's methods are members of a table module that are just a function instead of a regular value, since tables can have any type. so after loading stuff the above module would probably look like this:
CharacterAnimations: { LoadAllOntoCharacter = function() AnimationName = 123456789 }

#

sorry pressed enter too soon

#

will edit

#

you can also print a module with a method and it'll tell you the real interior!

maiden viperBOT
#

studio** You are now Level 1! **studio

ornate juniper
#

so whats the difference between using . and :

burnt pawn
#

i'm pretty sure the main difference is that : calls a function with the module as the first argument. so CharcterAnimations:LoadAllOntoCharacter() is actually CharacterAnimations.LoadAllOntoCharacter(CharacterAnimations).

ornate juniper
#

ts is so confusing lol

ornate juniper
burnt pawn
ornate juniper
#

alr got it

#

thanks for the help