----- IdleAnimations.lua v1.1 -----
If you think people will do something else while playing your episode (or the actual reason you want this, if you just like polish), this library is for you!
Make Mario taunt you, Luigi get pranked, make Toad cook, or let them blink or look at you; give your characters a little bit more life!
---- What changed in version 1.1? ----
Mostly bug fixes:
- Fixed an issue where sometimes Tie-ins give an error at the start of the level.
- Added IdleAnimations.IdleCooldown. Change this to have a longer waiting time after finishing an idle animation
- Fixed an issue where sometimes an idle animation plays right after another if it repeats at least once
- Idle Animations don't play anymore when holding something or riding a Yoshi/Shoe.
- Fixed multiple issues with IdleAnimations.playAnim().
- IdleAnimations.playAnim() also can't get interrupted anymore. (It's tie-ins still do, though!)
See some examples of the characters doing their own thing:
When Mario is bored...
Those boos are traumatising...
What is he cooking?
What you have to use when working with this library:
IA = require("IdleAnimations") -- first you'll have to load the library
To register an idle animation, use this function (preferably in function onStart()):
IA.registerIdleAnimation(
[IdleAnimationName],
[Graphics File;] Graphics.loadImageResolved("[yourFilename]"),
[Amount of Frames of your spritesheet],
[Time you need to be idle until it triggers at minimum; if it's -1 it will not trigger by staying idle],
[Maximum amount of time you have to wait on top of that (random range)],
[Time your idle animation takes; if 0, it lasts as long as you are staying idle] {[time on frame 1], [time on frame 2], [...]},
[player character; 1 for Mario, 2 for Luigi, 3 for Peach, 4 for Toad aso. (or you can use CHARACTER_MARIO aso)],
[How many the idle animation should repeat itself; if set to -1 it will repeat infinitely as long you are staying idle],
[If the idle animation should stop when you get airborn],
[OPTIONAL: Tie-in: the name of the idle animation that should play next; nil if nothing],
[OPTIONAL: gfxoffsetX: set a different offset than the norm (IA.gfxoffsetX)],
[OPTIONAL: gfxoffsetY: set a different offset than the norm (IA.gfxoffsetY)]
)
To play an Animation (doesn't need to be registered), use this function:
IA.playAnim(
[IdleAnimationName] (string),
[Graphics File;] Graphics.loadImageResolved("[yourFilename]"),
[Amount of Frames of your spritesheet] (number),
[(useless, but needs to be set anyways) Time you need to be idle until it triggers at minimum; if it's -1 it will not trigger by staying idle (number)],
[(useless, but needs to be set anyways) Maximum amount of time you have to wait on top of that (random range) (number)],
[Time your idle animation takes; if 0, it lasts as long as you are staying idle] {[time on frame 1], [time on frame 2], [...]},
[player character; 1 for Mario, 2 for Luigi, 3 for Peach, 4 for Toad aso. (or you can use CHARACTER_MARIO aso)],
[How many the idle animation should repeat itself; if set to -1 it will repeat infinitely as long you are staying idle (number)],
[If the idle animation should stop when you get airborn (true or false)],
[OPTIONAL: Tie-in: the name of the idle animation that should play next; nil if nothing],
[OPTIONAL: gfxoffsetX: set a different offset than the norm (IA.gfxoffsetX)],
[OPTIONAL: gfxoffsetY: set a different offset than the norm (IA.gfxoffsetY)]
)
You can execute code in these functions:
function onIdleAnimation(animName, animFrame, animTimer, animDuration, isRepeating) -- triggers while the idle animation is playing
-- animName: The name of the current Idle Animation
-- animFrame: The frame of the animation. Starts at 0
-- animTimer: A timer that counts up until it plays the next frame
-- animDuration: the amount of ticks the current Frame is shown before proceeding
-- isRepeating: only true when the idle animation repeats itself
end
function onIdleEnd(animName) -- triggers when the idle animation ends
-- animName: The name of the current Idle Animation
end
The following variables can be edited:
IA.isIdle = false / true -- you can manually make the player play an idle animation or stop an idle animation
gfxoffsetX = number -- set the offset so your spritesheet matches with the actual position of the player
gfxoffsetY = number -- ^
gfxwidth = number -- the width of the spritesheet itself. You probably doesn't need to change it, but if you need to, you can!
gfxheight = number -- the height of the spritesheet itself. ^
IdleCooldown = number -- Additional frames the player has to stay idle after finishing an idle animation without interrupting it.
The example level has some examples that should help you get it to work, so I'd recommend you to check out the luna.lua file
Remember to credit me when you use this library.
You want Luigi to drink coffee? Then here you go!
https://www.dropbox.com/scl/fo/ecj64e46 ... jsp4j&dl=0
If you want, for whatever reason, download the older version, here you go, I guess??
https://www.dropbox.com/sh/eaylbku7mh2v ... ElDya?dl=0