(Solved) How can i check if the player has completed a dialogue?

I’m making a simple dialogue tree, no options or anything i just want the player and an NPC to talk, and i’ve managed to make the text appear and proceed as expected. However i can’t seem to fix the end of the dialogue. Using different scripts i’ve managed to either make the same dialogue loop forever, or getting stuck on the last line forever. I think i could solve it if i had a condition or a variable that tells whether or not the player has reached the last line of the dialogue yet. How can i do that? Or if you seem to think of a better solution, how could i fix this? Code:

The condition check for if “backpack” is visible is just my spaghetti code way of checking if the menu is open.

The “if x button pressed” event is for skipping the dialogue entirely if you’ve already seen it.

My idea is to have an event that checks if the player has reached the final line and if they have and they also press “z” then i can run the actions from that “if x button pressed” event

You could use the condition ‘Branch title has been visited’, but that will only look out for whether a player has been to a certain node or not, rather than whether they read all the lines within that node. Usually the player will always see the last line of a branch and you can safely assume that they have, but you are giving the player the option of exiting dialogue at any time with your ‘x key is pressed’ so that makes things a little trickier. I don’t think there’s a built-in way of checking whether a player has seen individual lines of dialogue.

But you could use a Yarn variable or Yarn command in your dialogue, and then check in an event if the value of a yarn variable changed or if a command has been called. I use a Yarn variable in my game to set whether a line is the last line in a node. I use it to make a special graphic appear, but you could use it to do anything you like.

Note: the variable is set after the last line and can be called anything you like but must start with $. The $ is not needed in your event.

image

image

Another stumbling block is using Z for starting and moving through dialogue. The player might be pressing Z when they get to the end of dialogue, which means it’ll launch again immediately because Z also launches dialogue. 'key released for the ‘Clipped text has completed scrolling’ event should fix that.

Another tip: Yarn considers dialogue to no longer be running once the final letter from the final line has appeared on screen. Whether that final line stays on screen for a while after that before being hidden doesn’t matter to Yarn.

1 Like

I added an extra line of text to the end of each node that was simply " ." and then i had an event hide text and text box when dialogue wasn’t running anymore. Using this, the last line would show, then i clicked z and it starts writing out the " ." but as soon as it’s done it disappears so it’s shown for less than a single frame. I think i will switch to use a similar variable though, since yarn doesn’t seem to like empty or almost empty lines of text and it allows me to expand the dialogue system to include animations, icons for whoever is talking or whatever else. Thanks a ton for the help!