Vista Normal

Hay nuevos artículos disponibles. Pincha para refrescar la página.
AnteayerSalida Principal

Hack Your Own Adventure Story with Yarn Spinner

18 Mayo 2024 at 23:00

We are big fans of programmed texts for education. You know, the kind where you answer a question and go to a new page based on your answer. But they can also be entertaining “choose your own adventure” stories. You might say, “You are standing in front of an oak door, two meters high, with an iron handle. Do you a) open it? b) knock on it? c) ignore it?” Then, based on your answer, you go to a different part of the story. These are tough to write, but you can get some help using Yarn Spinner and the Yarn scripting language.

The original purpose of Yarn is to produce conversations for games. There’s a tutorial for that. The difference is to produce a book, you get a choose your own adventure PDF at the end. For the tutorial, you can try to read the text on the left-hand side of the editor or just press Test (at the top) and let it “read” the tutorial to you, which is a little more fluid.

The scripting language is mostly text, but you can have branching logic, which is critical for the book generation. You can also set variables as in:

<<set $gold to 5>>

Then you can test variables with <<if>> as you might expect. You can also jump to other parts of the script using <<jump>>. This works with nodes that look like this:

title: HackadayNode
---// Yarn script goes here===

That’s about it. We took the liberty of writing a cheeky Hackaday adventure. The source code is available, too. You’ll notice the script is simplistic. It doesn’t merge the lines, so if you have, say, three jumps to node X, you will get three copies of node X in the book. Then again, that helps your page count, and it doesn’t distract from the enjoyment of the finished product. And, yes, we added the title graphic after the fact.

It should be possible to write programmed instruction material with this, too. Why just pretend to submit a project to Hackaday when you could do it for real so easily?

❌
❌