Random dialogue from range? HELP! (Solved)

How do I make it so when this node is activated that the dialogue will be chosen randomly from among several options? Also, can I get some tips for yarn in gdevelop?

Hello. I haven’t tried doing what you’re doing (random lines), but I did a video about Yarn variables and if-blocks that you might find useful (below). I think you are looking at documentation for the latest version of Yarn (2.4), which is Unity only. GDevelop uses a much older version that’s no longer updated by the Yarn team. What you are trying to do might not work with our version of Yarn. There used to be documentation for it, but it seems that it’s been removed from the Yarn website. I expect a lot of the core features are the same, but there’s probably a lot in the new documentation that won’t work for us.

Edit: old docs are here: Welcome to Yarn Spinner | Yarn Spinner
(thank you Silver-Streak for the link)

Don’t let that put you off using Yarn. It’s a great tool and easier than setting up a dialogue system from scratch (unless you want something simple without options and commands). I just wish we had a newer version or an alternative that’s in active development.

This GDevelop Wiki page has links to some playable Yarn examples as well as talking about if-blocks etc.: The Dialogue Tree extension - GDevelop documentation

My video about Yarn variables and if-blocks:

1 Like

So create action to set scene number variable randominrange and then refer to the variable in a yarn node? Thanks.

Yes, I think I’d do it like that: get your random number with an action. Then pass that number to Yarn with a variable. Then do an if-statement inside Yarn, using that variable.

Another approach would be to launch a specific branch (node name) based on the random number. You wouldn’t need an if-statement in Yarn, but you would need a separate node for each random number.

image

1 Like

That looks promising to me :slightly_smiling_face:

Another way to do it is to create the random number at the same time you pass the value to Yarn, skipping the need for the BoarAttack scene variable.

1 Like