Keep in mind it is rough, even though I have added some error checking robustness code, which nearly doubled the LOC.
Comes with a sample xml file with an incredibly annoying but simple “adventure”. The script does showcase all that the interpreter can do.
Oh, and if you want to make an adventure that ends, have an option with a destination of “end”, or simply a room with no options (although this is not tested).
Today, I invented a new scripting language for interactive fiction.
I also wrote a console application in C# to play these scripts.
The script is XML based and has a schema like the following:
The player is about 150 LOC, does practically no error checking, but implements the full schema.
This was an idea I had some time in the last week. After reading Atwood’s CYOA post (where he quit his job), I thought about all of the Choose Your Own Adventure books I had as a kid, and similar books which are now referred to as interactive fiction.
And so I came up with a minimal set of functionality I would need to make my own IF language. I figured I needed:
- A way to inform the player of his current state.
- A way for the player to change his current state.
- The ability to have conditions that can be set, cleared, and tested
So, at the moment, I have a total of nine tags that the player can process.
- rooms: this is the root tag of the document, and contains all of the rooms.
- room: this represents a story node.
- text: the contents of this tag will be displayed to the user
- option: this represents a choice the player can make.
- set: this will set a flag variable
- clear: this will clear a flag variable
- if: this will execute the commands within it if a flag variable is set
- ifnot: this will execute the commands within it if a flag variable is clear
- include: this will execute the commands inside of another room
The “include” tag is not strictly necessary, but I put it in there to ease writing of scripts.
So, basically, I have written an interactive simple preprocessor.
Once I have a demo-able script, I’ll share it.