This is a C# (.NET) program which starts a YarnSpinner game, executes one turn, and exits. The input and output are JSON stanzas in the GlkOte format.
To run a Yarn game, it must be in the "machine-readable" JSON format produced by ysc --stdout. See YarnSpinner-Console.
The program relies on a modified version of the C# YarnSpinner library. (The modifications have to do with serializing the library state in mid-dialogue.) At present this exists as a fork on Github.
This script is meant to be used with the Discoggin Discord bot.
Install the current version of .NET if necessary. (That's 9.0 at the time of this writing.)
You also have to install the .NET 6.0 runtime for some reason known only to Microsoft.
Check out the YarnSpinner fork in directory YarnSpinner and switch to the autosave branch:
git clone [email protected]:erkyrath/YarnSpinner.git
cd YarnSpinner
git checkout autosave
cd ..
(The top level of the respository should now have both YSRun-Single and YarnSpinner directories. Sorry, it's a confusing arrangement.)
Now you can build the .NET application:
cd YSRun-Single
dotnet build
ysrun [ --start ] [ --autodir DIR ] GAME.yarn.json
If --start is used, we start the YS game, wait for the init event, and display the game's initial text.
If --start is not used, we attempt to load the YS game state from a file called autosave.json. (Use --autodir to determine what directory this file is found in.) Then we wait for a hyperlink event, select the choice, and display the game's response.
Either way, we write out autosave.json in preparation for the next turn.
The YSRunSingle.cs wrapper was written by Andrew Plotkin, and is in the public domain.
The YarnSpinner interpreter was created by Yarn Spinner Pty. Ltd., Secret Lab Pty. Ltd., and Yarn Spinner contributors; it is distributed under the MIT license.