How to make an animation to take priority over another? [GDScript]

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DaviBraid

Hi, I’m practicing GDScript by jamming a 2D platformer.
And for someone with 0 coding knowledge, I’m doing ok: I can make a character walk, jump, and kill a creature by throwing a lemon.

Here’s where it gets tricky:

I want the character to shoot while walking, but the animation has to change every time the character shoots (right and left arm). The drawing is made in layers [left arm/body/right arm] and seems entirely possible to combine those for a smooth running animation (although I didn’t quite manage to do that yet, seems possible), but I’m having real troubles to make the shooting animations (4 frames each) to happen and then have the engine revert to where the arm should be if the shot never happened.

I also want to add a side switching animation that would take over the running animation for a couple of frames before returning to the running animation (but not preventing the character from walking at the same speed). The side switching animation should not have priority (and should not appear) if the character is attacking through.

The solution might be really simple, but for a newbie, this has been a nightmare.
I appreciate any insights.