How to make dialogue tree that changes sprites?

Hey, y’all, I’m a newbie developer looking to make a dialogue tree that, depending on your choice, allows the player to do different animations (flipping in different directions), with dialogue at certain intervals.

After a certain number of frontflips, you’ll get a second choice, and regardless of what you pick, I’d like it to change back to the default backflip.

I’m having an issue where, after the second choice, no matter which one you pick, no flipping animation will play. This may be over my head for now, but I was hoping someone could help me see what I’m missing, if this is the right place for that? (sorry if it’s not!)

on confirm do
haveFlipped++
ignore
if haveFlipped==1 then
play "playerFlipFirst" then
say "WASN'T THAT FREAKING SICK!?!?!?!?" then
say "I'm not allowed to swear haha" then
swap "playerFront"
end
end
end
elseif haveFlipped==2 then
play "playerFlip" then
say "I spent a long time practicing this just for you! :>" then
swap "playerFront"
end
end
elseif haveFlipped==11 then
play "playerFlip" then
swap "playerFront"
say "OMG do you spend all your time doing flips!?!?!?" then
say "ME TOO!!!!" then
ask "What's your favorite kind of flip??" then
option "Back flip" then
favoriteFlip = 1
say "NO WAY!!! That's my favorite too!!! I knew we'd be awesome friends!!!"
end
option "Front flip" then
favoriteFlip = 2
say "Haha, yeah, I love front flips! They are so cool and epic!" // wouldn't it be so funny if i used one exclamation point to show that they're lying
end
option "Secret" then
favoriteFlip = 3
say "Oh, I see... I know exactly what you mean!! But I'm not sure if I can..."
end
end
end
end
end
elseif haveFlipped>=12 then
if favoriteFlip==2 then
play "playerFlipTry" then
triedFlips++
swap "playerFront"
if triedFlips==1 then
say "Heh, whoops, guess I'm off my pro gamer flip game today!"
swap "playerFront"
elseif triedFlips==3 then
say "I just need a minute to figure it out..." then
swap "playerFront"
end
elseif triedFlips==4 then
play "playerFlipTry" then
swap "playerFront"
say "Hey so." then
say "Um." then
say "I lied. I actually don't know how to do a front flip." then
ask "I'm sorry. Are you mad?" then
option "So mad" then
favoriteFlip = 0
wait 1 then
say "... I'm sorry. I won't lie to you again."
end
end
option "It's okay" then
favoriteFlip = 1
say "Really? That's so nice of you!!" then
say "It means we can match!! With your front flips, and my back flips, together, we'll be unstoppable!!"
end
end
end
end
end
end
end
else
play "playerFlip" then
swap "playerFront"
end
end
end
elseif favoriteFlip==3 then
play "playerFlip" then
swap "playerFront"
end
elseif favoriteFlip==1,0 then
play "playerFlip" then
swap "playerFront"
end
end
else
play "playerFlip" then
swap "playerFront"
end
end
listen
end

All the haveFlipped and flipsTried stuff are because I only want this stuff to happen after you press the button a bunch of times, so it’s a choice some players won’t get. I think my problem might be my variables getting tangled up or something, but there’s nothing I can see that could be mixing them up?

If I have to reformat this, does anyone have any suggestions as to how?

1 Like

Okay I tried rewriting it in a different format, which seemed to work much better. It’s not without flaw, but at least the animations are changing when I want them to :slight_smile:

If I’m supposed to delete posts like this once the issue has been resolved, please let me know, but for now, I’ll post the rewritten version in case anyone else might find it helpful!

on confirm do
if favoriteFlip==0 then // backflips
haveFlipped++
ignore
play "playerFlip" then
swap "playerFront"
end
listen
wait 0.6 then
if haveFlipped==1 then
say "WASN'T THAT FREAKING SICK?!?!?!?!?" then
say "I'm not allowed to swear haha"
end
elseif haveFlipped==2 then
say "I spent a long time practicing just for you!!"
elseif haveFlipped==3 then
say "OMG DO YOU SPEND ALL YOUR TIME DOING FLIPS!?" then
say "ME TOO!!!" then
ask "What's your favorite kind of flip?" then
option "Backflip" then
favoriteFlip = 1
say "NO WAY!! THAT'S MY FAVORITE TOO!!! I knew we'd be awesome friends!!"
end
option "Frontflip" then
favoriteFlip = 3
say "Oh, yeah, heh, front flips are totally epic!"
end
option "Secret" then
favoriteFlip = 2
say "Oh, I see... I know exactly what you're saying!! I'm just not sure if I can..."
end
end
end
end
end
end
elseif favoriteFlip==1 then // backflips (with love)
ignore
play "playerFlip" then
swap "playerFront"
end
listen
elseif favoriteFlip==2 then // sideflips
ignore
play "playerFlipSide" then
swap "playerFront"
end
listen
elseif favoriteFlip==3 then // frontflips
triedFlips++
ignore
play "playerFlipTry" then
swap "playerFront"
end
listen
wait 0.8 then
if triedFlips==1 then
say "Heh, whoops, guess I'm off my pro gamer flip game today!"
elseif triedFlips==2 then
say "Don't worry, I just need a second to figure it out..."
elseif triedFlips==3 then
play "playerFlipTry" then
play "playerFlipTry" then
say "Hey so" then
say "um." then
ask "I lied. I actually can't do a front flip. Are you mad?" then
option "So mad" then
favoriteFlip = 0
wait 1.5 then
say "... I'm sorry. I won't lie to you again."
end
end
option "It's okay" then
favoriteFlip = 1
say "Really!? That's so nice of you!!" then
say "With your frontflips and my backflips, together we'll be unstoppable!!"
end
end
end
end
end
end
end
end
end
end
end