Once
Learn about once statements, which let you specify content that only runs once.
Last updated
Learn about once statements, which let you specify content that only runs once.
Last updated
In Yarn Spinner 3, you can use a once
statement to run content only one time. When the script reaches a once
statement, it checks to see if itโs run before. If it has, it skips over it! Magic.
once
statements are great for making sure that the player never sees certain content more than once. For example, you might want a character to never introduce themselves to the player twice.
There are two main ways you can use a once
statement, which we'll explore below.
<<once>>
and <<endonce>>
:You can also use an <<else>>
clause within the <<once>>
statement, which will be run if the relevant <<once>>
content has already been seen:
You can also add an if
to the once
to run content a single time, but only when a certain condition is true. In all other cases, it will be skipped (or the else
content will be run, if there is any):
<<once>>
to a line, or options:If you add once
(or once if
) to a line, that line will only appear once, and will be skipped over every other time itโs encountered:
Similarly, if you add it to an option, that option will only be selectable once, and will be marked as unavailable after itโs been selected.
once
statements are really useful when you want to show long, detailed content the first time itโs encountered, but you donโt want to show it every time. This means that players donโt need to mash the โskip lineโ button over and over when they realise that theyโre starting to see a long run of lines theyโve already seen:
once
statements keep the information about whether theyโve been run or not in a variable thatโs stored in your Dialogue Runnerโs Variable Storage, just like any other variable. The variable isnโt directly accessible from your Yarn scripts.
This version of the documentation (docs.yarnspinner.dev/next) is for the current beta version of Yarn Spinner 3 (Beta 1). For Yarn Spinner 2.x, visit https://docs.yarnspinner.dev